可以请参见导航视图中的后退按钮
由于某种原因,我看不到导航视图中的后退按钮。
我不知道我是否需要在孩子视图中添加一些额外的代码,但我不知道。我或多或少从教程中复制了代码,但是我看不到孩子视图中的后退按钮。
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为您使用
.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.