我正在使用苹果的官方教程学习SwiftUI
:
https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation个
一切都很正常,直到我试着拨打.navigationBarTitle
在NavigationView
上显示导航标题.
我try 刷新实时视图,重新启动Xcode,但它仍然没有显示.
以下是我的代码:
import SwiftUI
struct LandmarkList : View {
var body: some View {
NavigationView {
List(landmarkData) { landmark in
LandmarkRow(landmark: landmark)
}
}
.navigationBarItem(title: Text("Done"))
.navigationBarTitle(Text("Landmarks"))
}
}
#if DEBUG
struct LandmarkList_Previews : PreviewProvider {
static var previews: some View {
LandmarkList()
}
}
#endif
Xcode如下所示:
根据教程,它应该显示导航标题,但在我的示例中没有.
知道为什么吗?谢谢!