Specifying UISegmentedControlNoSegment to UISegmentedControl's selectedSegmentIndex has no Effect on iOS 13

I asked this question earlier today: https://stackoverflow.com/q/57904625/347339


The proposed solution seems very hacky to me... Is this something Apple overlooked for iOS 13? Has anyone else encountered this and has come up with not a "hacky" solution?

Replies

Which assignment is not respected ? When you set a negative value ?


Could you post your code here also, for convenience (video on SO is OK, but code should also be visible here).


Some checks:

- Did you check that isMomentary is false ?

- in the following


- (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;
  }
}


could you test the value of integer

could you try to add a setNeedsDisplay on the segmentyedControl after line 4

I'm having this issue as well. Setting the .selectedSegmentIndex to .noSegment actually works internally, as the control will now return that no segment is currently selected. HOWEVER, the user is still seeing the most recent pressed segment as still highlighted. If you press the Home key, pushing the app into the background, then immediately bring it back to forground, the user now correctly sees a control with no selection. This problem did not exist until 13.0.


@IBOutlet weak var scGrid  : UISegmentedControl!
     ...
** User presses some button on the control **
** Then later in code **
     ...
     ...
self.scGrid.selectedSegmentIndex = UISegmentedControl.noSegment

Does a setNeedsDisplay change anything to it ?


Otherwise, could be worth a bug report.