только что последовал за учебником здесь , но я получаю ошибку Generic parameter 'Label' could not be inferred
в строке NavigationLink. Я попытался найти ошибку, но ничего не нашел, как ее решить. Xcode предлагает исправление явного указания параметров generi c, но я понятия не имею, что это значит. Это меняет мой код на NavigationLink<Label: View, Destination: View>(destination)....
@State var imageData : Data = .init(capacity: 0)
@State var show = false
@State var imagepicker = false
@State var source : UIImagePickerController.SourceType = .photoLibrary
var body: some View {
NavigationView {
ZStack {
NavigationLink(destination: ImagePicker(show: $imagepicker, image: $imageData, source: source), isActive: $imagepicker) {
Text("")
}
VStack {
if imageData.count != 0 {
Image(uiImage:UIImage(data: self.imageData)!)
.resizable()
.clipShape(Circle())
.frame(width: 250, height: 250)
.overlay(Circle().stroke(Color.red, lineWidth: 5))
.foregroundColor(Color.purple)
} else {
Image(systemName: "person.fill")
.resizable()
.clipShape(Circle())
.frame(width: 250, height: 250)
.overlay(Circle().stroke(Color.red, lineWidth: 5))
.foregroundColor(Color.purple)
}
Button(action: {
self.show.toggle()
}){
Text("Take a photo!")
.frame(width: 150, height: 150, alignment: .center)
.background(Color.green)
}
}.actionSheet(item: $show) {
ActionSheet(title: Text("Take a photo or select from photo library"), message: Text(""), buttons:
[.default(Text("Photo Library "), action: {
self.source = .photoLibrary
self.imagepicker.toggle()
}), .default(Text("Camera"), action: {
self.source = .camera
self.imagepicker.toggle()
})]
)
}
}
}
}