SwiftUI:NavigationBarItem 前导不显示

SwiftUI: NavigationBarItem leading does not show up

使用这段代码,为什么 navigationBarItem 不显示? 该视图在 sheet 中被调用,但这在之前并不重要...

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 未显示:

对于两侧项目使用此变体(测试与 Xcode 11.2 / iOS 13.2 一起使用):

ScrollView {
    changePassword
}
.navigationBarItems(leading: backButton, trailing: finishButton)