I have set a UITabBarController as the root view controller in the AppDelegate.
I have added a loading view upon the window, while the app downloads some data. I have hidden the status bar while the loading screen is visible. As soon as the loading is done, I fade the loading view and shows the status bar again.
My problem is that when I show the status bar the navigation bar was not drawn to have the right height, because the status bar was hidden when it was drawn. If I change to another tab it gets the right height.
I have tried with [navigationController.view setNeedsLayout], but that seems to get the position of the view of the ViewController right, but the content of the navigation bar does not resize. I have also tried with [navigationController.navigationBar setNeedsLayout], but that does help at all.
So I basically want to get the navigation drawer get the right height for the status bar and content when the loading view fades. How can I do this?
Have you try to reset the navigation and status bar as like below?
-(void)resetNavigationBar
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
[self.navigationController setNavigationBarHidden:YES];
[self.navigationController setNavigationBarHidden:NO];
}
I would unhide the status bar in the viewWillDisappear: method on the loading view.
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}
Related
I have a custom navigation and Home view in my app. On the click of button I want to show a View just like a left side view ( width is not equal to screen width) , on the top of navigation.
I have tried this:
LeftView.Layer.ZPosition = 1;
It is not working. If I set the Z index of navigation to -1, this hides complete navigation bar.
Try this :
[self.navigationController.view addSubview:yourSubView];
Try to add that view to UIWindow. This will add your view above navigation bar.
[[[[UIApplication sharedApplication] delegate] window] addSubview:yourView];
Add your custom navigation bar to the main view manually instead of using navigation controller's standard navigation bar. Then add your leftview as subview, in your main view. It will overlap navigation bar in this hierarchy.
This is a correct answer:
[self.navigationController.view addSubview:yourSubView];
Though it will not set the correct frame for the view, To set the correct frame for your view on the navigation bar, you have to set it in the viewDidAppear.
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.navigationController.view addSubview:mTitleView];
}
I have a navigation view controller. The root view hides the navigation bar using self.navigationController?.navigationBarHidden = true.
No matter what I do I cannot get thestatusBar to be translucent it is simply a white block that pushes my content below.
You can make status bar translucent as -
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
// set full screen layout in view controller class
self.wantsFullScreenLayout = YES;
How can I hide the navigation bar by not hiding the status bar in my app? When I try [self.navigationController.navigationBar setHidden:YES]; it also hides the status bar. I need to show the status bar like this:
I need to first hide a visible navigation bar, make the status bar still visible and I also have a view that I need to move below the status bar, but the view is being positioned like the navigation bar is still there when I set the frame's position to 0,0.
I setup my statusbar as:
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Add this to your code where you want to hide the navigation bar
[self.navigationController.navigationBar setHidden:YES];
If you want to hide navigation bar but show status bar, you should set Top Space to Top Layout Guide as 0 instead of -44. and then
Hide navigation bar in viewWillAppear instead of viewDidLoad: [self.navigationController setNavigationBarHidden:YES animated:YES]
I start to set top space as -44, then call method [[UIApplication sharedApplication] setStatusBarHidden:NO], it doesn't work.
In my case, the status bar text and symbols were not shown because they had the same color as the background (black). I solved the problem by changing the background color:
[self.navigationController.navigationBar.superview setBackgroundColor:UIColor.whiteColor];
I have a view controller that displays full screen, and from the view controller another modal VC can be presented, the modal VC requires status bar, but after dismissing the modal VC controller, the base VC has the space for status bar on top, and even I set:
[[UIApplication sharedApplication] setStatusBarHidden:YES]
the status bar is hidden but the space is still there, and I checked the frame of the view of the base VC, it starts from 0, I don't think I should make its y-coordinate starts from -20, but what else can I do?
Thanks
Try this out:
[[UIApplication sharedApplication] setStatusBarHidden:NO];
self.view.frame = [[UIScreen mainScreen] applicationFrame];
From the docs on applicationFrame:
This property contains the screen bounds minus the area occupied by
the status bar, if it is visible. Using this property is the
recommended way to retrieve your application’s initial window size.
The rectangle is specified in points.
For a more robust solution, change your frame in response to a status bar frame change. Your application delegate subclass can implement:
-application:willChangeStatusBarFrame:
-application:didChangeStatusBarFrame:
Or, you can register for these notifications using NSNotificationCenter:
UIApplicationWillChangeStatusBarFrameNotification
UIApplicationDidChangeStatusBarFrameNotification
I've tried your method, but it did not work for me, I solved it in this way, when the modal VC dismisses, in the viewDidAppear of base VC I need to:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
self.wantsFullScreenLayout = YES;
[self.view layoutSubviews];
I know this is not a good solution, but it is the only thing I could think of at the moment, thanks anyway for your help.
I find that UIViewController's view's coordinate is (0,20),size is 1024*748 in MainStoryboard_iPad.storyboard ,and I can't change.How can I change view to (0,0) and size is 1024*768 ,so I can show the view full sceen.
It is Due to status bar of size 20 present on the top.
In the storyboard you could go to attributes inspector and change Status bar to none.
Which will show full view of size (1024, 768)which can be helpful for setting view by storyboard.
And than in view controller's .m file write below method :
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:NO];
}
That is probably because of the status bar. You can hide the status bar as such [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];