我已经安装了 Xcode 11,正如苹果在https://developer.apple.com/tutorials/swiftui/creating-and-combining-views链接中所建议的,我打开了对象库,但只有三个选项,一个用于代码片段,第二个用于媒体,第三个是颜色,但在右上角的 + 图标中看不到对象库
1)尝试按照苹果的建议打开对象库。
请看这个截图
应该显示对象库
由于NavigationButton不再可用,我如何检查NavigationLink中的条件以便导航到另一个视图?
NavigationLink(destination: Dashboard(userName: self.userId,
password: self.password), isActive: $showDashboard) {
Button(action: {
if self.userId.isEmpty || self.password.isEmpty {
self.isAlert = true
} else {
self.showDashboard = true
}
}) {
Text("Submit")
.foregroundColor(.white)
.font(.system(size: 22))
Dashboard()
}
.frame(minWidth: 150, idealWidth: 300, maxWidth: 450,
minHeight: 30, idealHeight: 40, maxHeight: 50, alignment: .center)
.background(Color(red: 81/255, green: 221/255, blue: 182/255))
.padding([.leading, .trailing], 20)
}
Run Code Online (Sandbox Code Playgroud)
编辑:-
另外,如果用户名和密码的长度超过 16,我想显示警报;如果长度超过 10,则显示不同的警报;如果长度为 0,则显示空消息警报。