I would like to control the display/hide of NavigationBar
and StatusBar
in one iOS application.
iPhone6, iPhone7 and iPhone8 display as intended.
The status bar and navigation bar are not displayed on the first screen.
On the next screen, the status bar remains hidden and the navigation bar appears.
However, on iPhoneX, NavigationBar
will also be displayed.
prefersStatusBarHidden
in ViewController is set to YES.
Also, the height of NavigationBar
will be similar to that of StatusBar
.
If you know the solution, please let me know.
I look forward to your kind cooperation.
The code looks like the following.
FirstViewController.m
- (void) viewDidLoad
{
superviewDidLoad;
self.view.backgroundColor=UIColor.yellowColor;
self.navigationController.navigationBarHidden=YES;
} }
- (void) viewWillAppear: (BOOL) animated
{
super viewWillAppear: animated;
self.navigationController.navigationBarHidden=YES;
}
- (void) touchUpButton: (UIButton*) button
{
SecondViewController* vc = [[SecondViewController alloc] init];
[self.navigationController pushViewController:vcanimated:YES];
}
- (BOOL) preferStatusBarHidden
{
return YES;
}
SecondViewController.m
- (void) viewDidLoad
{
superviewDidLoad;
self.navigationController.navigationBarHidden = NO;
self.navigationItem.title=@"SecondView";
self.view.backgroundColor=UIColor.cyanColor;
}
- (void) viewWillAppear: (BOOL) animated
{
self.navigationController.navigationBarHidden = NO;
}
- (BOOL) preferStatusBarHidden
{
return YES;
}
I also asked a question on StackOverFlow at my home (English version), but iPhoneX behavior, so it is not possible to display the navigation bar and not display the status bar.
Also, I was aware of it, but Apple's UI guidelines suggest that iPhoneX should display the status bar.
© 2024 OneMinuteCode. All rights reserved.