I am the maintainer of STAControls which subclasses various UIControl
s, one of which is UISegmentedControl
. Within that project's sample app, I have the following code (can be downloaded from the aforementioned link):
- (void)textFieldDidEndEditing:(UITextField *)textField {
NSInteger integer = [textField.text integerValue];
if (integer < 0 || integer >= self.segmentedControl.numberOfSegments) { this doesn't work
self.segmentedControl.selectedSegmentIndex = UISegmentedControlNoSegment;
} else { // this works
self.segmentedControl.selectedSegmentIndex = integer;
}
}
In iOS 13 the UISegmentedControlNoSegment
assignment is not respected:
While in iOS 12 and prior versions of iOS this performs just fine:
Any idea(s) on how to work around this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…