可以请参见导航视图中的后退按钮

发布于 2025-02-02 07:09:17 字数 1973 浏览 3 评论 0原文

由于某种原因,我看不到导航视图中的后退按钮。

我不知道我是否需要在孩子视图中添加一些额外的代码,但我不知道。我或多或少从教程中复制了代码,但是我看不到孩子视图中的后退按钮。

    var body: some View {
        VStack {
            //Rectangle 12
            Rectangle()
                .fill(Color(#colorLiteral(red: 0.7137255072593689, green: 0.10196077823638916, blue: 0.10196077823638916, alpha: 1)))
                .frame(width: .infinity, height: 50)
                .padding(.bottom, 0.0)
            
            
            NavigationView {
                ZStack{
                    Color(red: 0.9, green: 0.9, blue: 0.9).edgesIgnoringSafeArea(.all)
                    
                    
                    ScrollView(.vertical, showsIndicators: true) {
                        
                        HStack{
                            Text("Marketplace").font(.custom("Arial", size: 35))
                                .fontWeight(.medium)
                                .foregroundColor(Color(red: 0.1, green: 0.1, blue: 0.1))
                                .padding(EdgeInsets(top: 15, leading: 20, bottom: -2, trailing: 0))

                            Spacer()
                        }
                
                        ForEach(produitsdfsdf, id: \.id ) { product in
                            
                            NavigationLink(destination: TempView()) {
                                LandingPresets.listItem(name: product.name, description: product.price, rate: product.category)
                            }
                        }
                        
                    }
                    .navigationBarHidden(true)
                    
                }
            }
            .padding(.top, -8.0)
            
            
        }.ignoresSafeArea(edges: .top)
            .onAppear {
                ProductAPI().getAllProducts {(productArr) in
                    self.produitsdfsdf = productArr
                }
            }
        
        
    }

For some reason I can't see the back button in the Navigation View.

I don't know if there is some extra code that I need to add in the child view but I don't know. I more or less copied the code from the tutorial, but I can't see the back button in the child view.

    var body: some View {
        VStack {
            //Rectangle 12
            Rectangle()
                .fill(Color(#colorLiteral(red: 0.7137255072593689, green: 0.10196077823638916, blue: 0.10196077823638916, alpha: 1)))
                .frame(width: .infinity, height: 50)
                .padding(.bottom, 0.0)
            
            
            NavigationView {
                ZStack{
                    Color(red: 0.9, green: 0.9, blue: 0.9).edgesIgnoringSafeArea(.all)
                    
                    
                    ScrollView(.vertical, showsIndicators: true) {
                        
                        HStack{
                            Text("Marketplace").font(.custom("Arial", size: 35))
                                .fontWeight(.medium)
                                .foregroundColor(Color(red: 0.1, green: 0.1, blue: 0.1))
                                .padding(EdgeInsets(top: 15, leading: 20, bottom: -2, trailing: 0))

                            Spacer()
                        }
                
                        ForEach(produitsdfsdf, id: \.id ) { product in
                            
                            NavigationLink(destination: TempView()) {
                                LandingPresets.listItem(name: product.name, description: product.price, rate: product.category)
                            }
                        }
                        
                    }
                    .navigationBarHidden(true)
                    
                }
            }
            .padding(.top, -8.0)
            
            
        }.ignoresSafeArea(edges: .top)
            .onAppear {
                ProductAPI().getAllProducts {(productArr) in
                    self.produitsdfsdf = productArr
                }
            }
        
        
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞花火° 2025-02-09 07:09:17

这是因为您使用.navigationbarhidden(true)在主视图中。
您可以将.navigationbartitledisplaymode(.inline)添加到tempview()。
如果您提供tempview代码,我将能够显示代码的哪一部分。

It is because of you use .navigationBarHidden(true) in main View.
You could add .navigationBarTitleDisplayMode(.inline) to your TempView().
If you give code of TempView, I'll be able to show to which part of code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文