未解析的标识符 NavigationButton 错误
Unresolved identifier NavigationButton error
我是 swiftUI 的新手,只是想弄清楚基础知识。我只是想创建一个新视图和一个将移动到它的按钮。
当我使用下面的代码时,出现错误:"Use of unresolved identifier 'NavigationButton'" 尽管它是由 Xcode 生成的。
import SwiftUI
struct HomeView: View {
var body: some View{
NavigationView {
NavigationButton(destination: NextView()) {
Text("Navigate 1")}
}
}
}
NavigationButton
暂时改为 NavigationLink
。所以替换它并使用它。
NavigationLink
替换 NavigationButton
,下面的代码是 WWDC 2019 Introducing SwiftUI: Building Your First App
的更新
struct RoomCell: View {
let room: Room
var body: some View {
NavigationLink(destination: RoomDetail(room: room)) {
Image(room.thumbnailName)
.cornerRadius(8)
VStack(alignment: .leading) {
Text(room.name)
Text("\(room.capacity) people")
.font(.subheadline)
.foregroundColor(.secondary)
}
}
}
}
我是 swiftUI 的新手,只是想弄清楚基础知识。我只是想创建一个新视图和一个将移动到它的按钮。
当我使用下面的代码时,出现错误:"Use of unresolved identifier 'NavigationButton'" 尽管它是由 Xcode 生成的。
import SwiftUI
struct HomeView: View {
var body: some View{
NavigationView {
NavigationButton(destination: NextView()) {
Text("Navigate 1")}
}
}
}
NavigationButton
暂时改为 NavigationLink
。所以替换它并使用它。
NavigationLink
替换 NavigationButton
,下面的代码是 WWDC 2019 Introducing SwiftUI: Building Your First App
struct RoomCell: View {
let room: Room
var body: some View {
NavigationLink(destination: RoomDetail(room: room)) {
Image(room.thumbnailName)
.cornerRadius(8)
VStack(alignment: .leading) {
Text(room.name)
Text("\(room.capacity) people")
.font(.subheadline)
.foregroundColor(.secondary)
}
}
}
}