My code ran until I started organizing files into folders. I then received an ambiguous reference error. I tried ungrouping the files but the error remained. The compiler is not recognizing the usage of the '==' operator to test between a string stored in an struct and a string literal.
I'm really too new to SwiftUI to know what else I can try. However, I have tried doing the same in a test project with very simple code and I know that I should be able to use an if, the "==" operator
struct MainViewRow: View {
var mainviewitem: MainViewItem
var body: some View {
HStack {
Image(mainviewitem.imageName)
.resizable()
.frame(width: CGFloat(30), height:CGFloat(30) )
Text(mainviewitem.actionname)
Spacer()
if mainviewitem.actionname == "action1" {
NavigationLink("", destination: VitalsView(mainviewitem: mainviewitem))
.navigationBarHidden(false)
}
else if mainviewitem.actionname == "action2" {
NavigationLink("", destination: MedicalRecordsView(mainviewitem: mainviewitem))
.navigationBarHidden(true)
}
else if mainviewitem.actionname == "action3" {
NavigationLink("", destination: FeedingView(mainviewitem: mainviewitem))
.navigationBarHidden(true)
}
else if mainviewitem.actionname == "action4" {
NavigationLink("", destination: QuestionsForVetView(mainviewitem: mainviewitem))
.navigationBarHidden(true)
}
else if mainviewitem.actionname == "action5" {
NavigationLink("", destination: RecallsView(mainviewitem: mainviewitem))
.navigationBarHidden(true)
}
else if mainviewitem.actionname == "action6" {
NavigationLink("", destination: ParksView(mainviewitem: mainviewitem))
.navigationBarHidden(true)
}
} // HStack
} //body
} // struct
Aucun commentaire:
Enregistrer un commentaire