0

我目前有一个嵌入了 navigationLink 的 navigationView,它通向一个包含 HStack 和 List 的 VStack。出于某种原因,当我拖回堆栈中的上一个导航并中途离开时,应用程序出现故障并需要重新启动。仅当我包含导航栏标题时才会发生这种情况。

这是嵌入在导航视图中的视图的代码。删除 HStack 会导致代码错误停止。导航栏项目部分对于我想要的行为来说不够大。

期望行为:静态 HStack,其下方有一个列表和导航栏标题。

任何帮助,将不胜感激。谢谢。

struct Sell: View {
var body: some View {
    NavigationView {
        List(self.stores) { store in
            NavigationLink(destination: StoreHome2(store: store)) {
                VStack(alignment: .center) {
                    Text(store.storeName)
               
                }
            }
        }.navigationBarTitle(Text("Sell").foregroundColor(Color.black))
    }.onAppear(perform: getStores)
}
}

import SwiftUI

struct StoreHome2: View {
    var categoryItem: [String: [Item]]
    var store: Store
    @State var isPresentingFirst = false

    var body: some View {
        VStack {
            HStack {
                Button(action: {
                    self.isPresentingFirst = true
                }) {
                  Image(systemName: "plus")
                }.sheet(isPresented: $isPresentingFirst) {
                    EmptyView()
                }
            }.padding()

            List {
                ForEach(categoryItem.keys.sorted(), id: \.self) { key in
                    Text("Hello World")
                }.listRowInsets(EdgeInsets())
            }

        }.navigationBarTitle(Text("Hello World"))
    }
}
4

0 回答 0