Ios ';字体';不可转换为';字体?';在SwiftUI教程中
在AppleIos ';字体';不可转换为';字体?';在SwiftUI教程中,ios,swiftui,xcode11,Ios,Swiftui,Xcode11,在AppleSwiftUI教程中,我遇到了一些错误 在本教程中,在步骤8、9、10之后,将发生错误 这是我写的: import SwiftUI struct LandmarkDetail : View { var landmark: Landmark var body: some View { VStack { MapView(landmark.locationCoordinate) .edgesIgnoringSafeArea(.top
SwiftUI
教程中,我遇到了一些错误
在本教程中,在步骤8、9、10之后,将发生错误
这是我写的:
import SwiftUI
struct LandmarkDetail : View {
var landmark: Landmark
var body: some View {
VStack {
MapView(landmark.locationCoordinate)
.edgesIgnoringSafeArea(.top)
.frame(height: 300)
CircleImage(landmark.image(forSize: 50)).offset(y: -130)
.padding(.bottom, -130)
VStack(alignment: .leading){
Text(landmark.name)
.font(.title)
HStack{
Text(landmark.park)
.font(.subheadline)
Spacer()
Text(landmark.state)
.font(.subheadline)
}
}
.padding(30)
Spacer()
}
}
这段代码运行良好,没有任何错误
但将某些常量更改为变量后,会出现这些错误
我曾多次尝试重新启动Xcode,但都不起作用
怎么了
以下是苹果公司所写的内容:
var body: some View {
VStack {
MapView(coordinate: landmark.locationCoordinate)
.frame(height: 300)
CircleImage(image: landmark.image(forSize: 250))
.offset(y: -130)
.padding(.bottom, -130)
VStack(alignment: .leading) {
Text(landmark.name)
.font(.title)
HStack(alignment: .top) {
Text(landmark.park)
.font(.subheadline)
Spacer()
Text(landmark.state)
.font(.subheadline)
}
}
.padding()
Spacer()
}
Xcode:11.0版beta版(11M336w)更改这两行
MapView(landmark.locationCoordinate)
.edgesIgnoringSafeArea(.top)
.frame(height: 300)
CircleImage(landmark.image(forSize: 50)).offset(y: -130)
.padding(.bottom, -130)
对此,
MapView(coordinate: landmark.locationCoordinate)
.edgesIgnoringSafeArea(.top)
.frame(height: 300)
CircleImage(image: landmark.image(forSize: 50)).offset(y: -130)
.padding(.bottom, -130)