I've read a few questions here and searched around a bit but nothing seems to solve my problem. I have a side navigation controller of which I am sliding the status bar (using a technique outlined here: Moving status bar in iOS 7).
In any event, when I hide the status bar to begin the slide (as soon as I tell the view to hide the status bar and add a fake one), the entire view moves up behind my faux status bar. Is there any way to move the view down so that the faux status bar appears directly above the view?
may be some autolayout issueAs there is no status bar , the view frame went to frame.origin.y=0. Try setting the frame to origin.y=20 before you hide the status bar.
If you are adding fake status bar as subview to mainView. set frame of fake status bar view to (origin.y=-20)
Related
I created a new view controller and connected it up in an existing storyboard. I can see the status bar on all the preceding screens, but not on this one. There is just a white bar where it should be. I'm not doing anything to hide the status bar!
I have no idea why, but the base view of my view controller was not transparent. When I made the background color of the base view of the view controller transparent, I could see my status bar again.
Weird iOS 7 issue I am having.
I have a UINavigationController added as a child view controller to my main view controller.
When I hide the status bar (by setting preferredStatusBarHidden and calling setNeedsStatusBarAppearanceUpdate), the navigation controllers top view controller recesses the 20 pixels that the status bar did, but not the UINavigationBar. This is only happening on iOS 7 - and I cannotfind a work around. If I rotate the device, it corrects the issue?
Before I hide the status bar
After I hide the status bar
I have tried calling layoutIfNeeded and updateViewConstraints. These did nothing. Was able to do conditional checks for version number and add constraints to fix, but this breaks things worse on rotate and I would prefer a cleaner solution if anyone has any ideas.
Thanks.
When hiding the status bar in a UINavigationController-based app by using:
UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: .None)
the UINavigationBar's frame is adjusted. This is because the status bar is a UIView itself and the top of the navigation bar is constrained to the bottom of the status bar. So when the status bar is moved offscreen, the navigation bar moves up with it.
I've tried a number of ways to prevent this behavior. I've tried manually assigning a frame to the navigation bar to no avail. I've tried subclassing UINavigationBar and overriding sizeThatFits() while checking if the status bar is hidden or not and assigning a frame that way. Nothing. I've read other SO posts but no one seems to have a working solution. Help?
This is getting very frustrating for me because I can't get the status bar to appear in my app. Everything related as far as UI is done on storyboard. when i set my status bar:inferred, top bar: inferred in my navigation controller, the status bar shows up fine. However, I do not want the top bar to appear as it interferes with my layout, so I set the top bar to none, which results in no top bar or status bar.
How can I just make the status visible without affecting my layout? (auto-layout is enabled)
So I did more googling and research, turns out I just had to add View controller-based status bar appearance as the key and the value as NO in the .plist file
With the status bar initially visible, I add a subview and hide the status bar:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
[myController.view addSubview:anotherController.view];
In this view there is a button to toggle the status bar visibility, but when I set statusBarHidden to NO again, the view controller's view doesn't auto resize to take into account the status bar, and as a result the view is pushed down and cut off by 20px. I've set all the appropriate resizing masks to the view and also tried auto-layout, but neither seem to work. I'd like my view to resize automatically when showing/hiding status bar without manually setting its frame.
Update
Instead of adding it the root view controller's view, I've pushed it onto the stack of my navigation controller, and hidden the status bar and navigation bar. I then give the user the option to toggle only the status bar. However the problem still remains and the view is pushed and cut off by 20px when the status bar reappears.
But when I rotate the device, everything is in its place - only if I rotate the device after the status bar has been hidden.
How is myController added to the window? Assuming that myController is the rootViewController of your window, than this controller should resize correctly when displaying / hiding the statusBar. The view of anotherController should be added in another way, than just adding its view. But still, if you give that view the correct resizing flags, it should also resize. But it would be better, if you push that controller on a navigationController, or if you set it as the new rootViewController.