Reputation: 1
enter image description hereI am new to SwiftUI. When I embed a toggle switch inside Vstack, it says "generic param Label cannot be inferred" in SwiftUI. May I know the cause for this error and how to fix it.Thank you
Upvotes: 0
Views: 58
Reputation: 1
I have embedded a text, Two toggles and stepper and a button in Vstack and here I have missed to provide action to that button, which resulted in the issue "generic param Label cannot be inferred".previous Code with issue. After adding the button action
Upvotes: 0
Reputation: 472
Looks like you might have missed specifying the label or have an error there. I have created the below code that has a toggle button inside VStack.
import SwiftUI
struct ContentView: View {
@State private var isOn: Bool = false
var body: some View {
VStack (alignment: .leading, spacing: 10){
Toggle(isOn: $isOn){
Text("Toggle me to set values")
}
Text("Toggle Value: \(isOn.description)")
Spacer()
}.padding()
}
}
Let me know if this helps.
Upvotes: 1