I have an application with 2 viewcontrollers, ViewController and NextViewController. ViewController does not have a navigation bar and has a white status bar. NextViewController does have a navigation bar and has a black (default) status bar. I have encountered a bug when swiping back to ViewController from NextViewController and cancelling the swipe where the navigation bar on NextViewController will disappear. The storyboard simply has the two views with a button and an action segue. The bug does not always happen, but often enough to be a problem. The bug has to do with the method - (UIStatusBarStyle) preferredStatusBarStyle
, as everything works fine when I remove the methods.
Can I somehow stop this bug from happening while still having a white status bar on my ViewController and having the swipe enabled or am I forced to remove either functionality?
ViewController
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setNeedsStatusBarAppearanceUpdate];
}
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
- (UIStatusBarStyle) preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
NextViewController
@implementation NextViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setNeedsStatusBarAppearanceUpdate];
}
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleDefault;
}
Other possibly relevant info: Experiencing the issue on an iPhone 5s with iOS 8, but it also happens on the simulator with iOS 9. View controller-based status bar appearance is set to the default, YES.