有了这段代码,为什么navigationBarItem 不显示?该视图在工作表中被调用,但这在之前并不重要......
struct ChangePasswordView: View {
@Environment(\.presentationMode) private var presentationMode
@State private var passwordNew = ""
@State private var passwordNewAgain = ""
var body: some View {
ScrollView {
changePassword
}
.navigationBarItems(leading: backButton)
.navigationBarItems(trailing: finishButton)
}
var backButton: some View {
Button(action: { self.presentationMode.wrappedValue.dismiss() }) {
Text("Cancel")
}
}
var finishButton: some View {
Button(action: {
self.changePasswordGlobally()
self.presentationMode.wrappedValue.dismiss()
}) {
Text("Apply")
}
.disabled(self.passwordNew.isEmpty || self.passwordNew != self.passwordNewAgain)
.disableAutocorrection(true)
}
}
正如您在以下屏幕截图中看到的,应该领先的 navigationBarItem 没有显示: