问题
I have a stepper control in the main list view as well as in the detail view. the code is exactly the same. However the stepper in main view is working perfectly, but the subview is stopping after 1 increment (as it looks like the upper bound is set.) The funny thing is it was working some time ago, after improvements, i am not able to trace what exactly changed it s behaviour.
Here is the code.
struct QuestionCardTest: View {
@Binding var question : SurveyQuestion
var body: some View {
NavigationLink(destination:QuestionCardDetailTest(question: $question)){
HStack(spacing: 0){
Text(question.questionText)
Spacer()
Text("\(self.question.ScaleInt) ")
Stepper(value: self.$question.ScaleInt, in: 0...100) {
Text("")
}
}
}
}
}
struct QuestionCardDetailTest: View {
@Binding var question : SurveyQuestion
var body: some View {
VStack
{
HStack{
Text("Answer (Numeric)")
Spacer()
Text("\(self.question.ScaleInt)")
Stepper(value: self.$question.ScaleInt, in: 0...100) {
Text("")
}
}
}
}
}
来源:https://stackoverflow.com/questions/59858800/swiftui-stepper-binding-is-not-working-in-the-subview