I have a container view controller which transitions from one child view controller to another child using this code:
- (void)switchToNewViewController:(UIViewController *)newController {
[self
transitionFromViewController:self.currentViewController
toViewController:newController
duration: 0.6
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
newController.view.frame = self.currentViewController.view.frame;
}
completion:^(BOOL finished) {
[self.currentViewController removeFromParentViewController];
[newController didMoveToParentViewController:self];
self.currentViewController = newController;
}
];
}
- (UIViewController*)childViewControllerForStatusBarStyle
{
return self.currentViewController;
}
I have a problem when the first view controller prefers dark text in the status bar but the next view controller prefers light text.
First view controller:
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleDefault;
}
Second view controller:
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
I put a breakpoint in both the first and second view controller's preferredStatusBarStyle. The debugger only breaks on the first view controller, but does not on the second view controller. As a result, the status bar style doesn't change. How would I notify the Cocoa framework that it needs to read the second view controller's preference?