Closed nderkach closed 7 years ago
Finally I was able to set it in viewDidLayoutSubviews
. You need to update the initial state after the view is laid out.
There was a delay for me using viewDidLayoutSubviews, so the user notice it. But I found another way. For anyone searching for this, you have to set currentState in viewDidLoad but you have to call [self.view layoutIfNeeded] right before !
- (void)viewDidLoad {
[super viewDidLoad];
[self.view layoutIfNeeded];
self.nbTeamsSegmentedControl.currentState = oldSelectedNbTeamsIndex; //saved in NSUserDefaults
}
It seems that it's impossible to set the default slider state (
setCurrentState
) untilviewDidAppear
. I've tried both inviewWillAppear
andviewDidLayoutSubviews
.