在导航栏向后推后,“ Go FirstPage 2”可以取消启动,但“ Go FirstPage 1”不能启动吗? 为什么〜上帝帮助我!
struct HomePage: View {
var body: some View {
NavigationView {
NavigationLink(destination: NewView()) {
Text("Go FirstPage 1")
}
.navigationBarItems(leading:leftBarItem)
}
}
var leftBarItem: some View {
NavigationLink(destination: NewView()) {
Text("Go FirstPage 2")
}
}
}
struct FirstPage {
var body: some View {
NewView()
}
}
struct NewView: UIViewRepresentable {
func makeCoordinator() -> NewViewCoordinator {
return NewViewCoordinator()
}
func updateUIView(_ uiView: UIView, context:Context) {}
func makeUIView(context:Context) -> UIView {
return context.coordinator.label
}
static func dismantleUIView(_ uiView: UIView, coordinator: Self.Coordinator){}
class NewViewCoordinator:NSObject {
lazy var label:UILabel = {
let titleLabel = UILabel(frame: CGRect(x: 100, y: 200, width: 100, height: 30))
titleLabel.text = "Hello"
titleLabel.textColor = .green
return titleLabel
}()
override init() {
print("NewView init.")
}
deinit {
print("NewView deinit.")
}
}
}