我在SwiftUi上遇到了一个大问题。真正简单的NavigationView层次结构中的“后退按钮”在第三个 View 上消失。如果我进一步查看,则“后退”按钮又在那里,我可以返回。
我搜寻了3小时,但只找到了这个SwiftUI: Back button disappears when clicked on NavigationLink
显然,这不能解决我的问题。
谢谢你的帮助!
最佳答案
对我来说,问题有点不同-后退按钮仅在与第三个 View 互动后才在第三个 View 上消失。单击进入 ListView 。
我的解决方法是使用旧的.navigationBarItems而不是.toolbar,因此:
.navigationBarItems(trailing:
Menu {
Button(action: {
//some action
}) {
//some label
}
Button(action: {
//some action
}) {
//some label
}
}
label: {
//some label
}
)
代替:.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Menu {
Button(action: {
//some action
}) {
//some label
}
Button(action: {
//some action
}) {
//some label
}
}
label: {
//some label
}
}
}
关于进入第三个 View ( Controller )后,SwiftUi导航栏按钮消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64409091/