【发布时间】:2020-09-25 08:18:32
【问题描述】:
我在 Swift 和 iOS 14 中遇到了 NavigationLink 的问题。这是一个已知问题,但是我看到的问题解决者还不够。我发现当一个带有NavigationLink 的按钮被提前初始化时,它可以工作,当你进入页面时,你有“返回”按钮。但是,当导航链接在中间时,进入页面后无法返回,必须关闭应用才能再次进入主屏幕。
这是我正在使用的代码:
HStack {
Button(action: {
if let url = URL(string: "I blacked this out to make no advert here") {
UIApplication.shared.open(url)
}
}){
Text("Rate App").foregroundColor(.gray)
}.modifier(navigationButtonViewStyle())
Spacer()
// this navigation link works fine
NavigationLink(destination: HelpView()) {
Text("FAQ").foregroundColor(.gray)
}.modifier(navigationButtonViewStyle())
}.padding(.horizontal, 20)
VStack {
Text("λSET")
.font(.largeTitle)
.fontWeight(.heavy)
.bold()
.padding(.top, 50)
.onAppear(perform: prepareHaptics)
.animation(.linear)
Text("λudio System Engineer Tools")
.fontWeight(.light)
.animation(.linear(duration: 0.5))
HStack {
Spacer()
// this navigation link is not showing the go back button when pressed and directed to the new screen
NavigationLink(destination: AboutView()) {
Text("About λSET")
.fontWeight(.heavy)
.bold()
}
Spacer()
}.modifier(calcTitleViewStyle())
.padding(.top, 20)
.padding(.bottom, 60)
}
我不确定问题是什么,但很好奇这可能是什么。我正在研究一种解决方法,但我很想从根本上解决问题。
谢谢!
【问题讨论】:
标签: swift swiftui swiftui-navigationlink