Swift UI : Unable to infer complex closure return type; add explicit type to disambiguate

Return only one view.

To do that, Group many views into one view:

Many Views

VStack(alignment: .center){
ForEach(my, id:\.self){row in
Button(action: {}){
Spacer()
Text("\(row)")}
Spacer()
}
}

Into one view with Group {}

VStack(alignment: .center){
ForEach(my, id:\.self){row in
Button(action: {}){
Group{
Spacer()
Text("\(row)")}
Spacer()
}
}
}
}

Written by

Don’t follow me. I wrote junks here. Follow me on Twitter instead.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store