iOS7 Status Bar over Navigation Bar - iphone

I'm testing my application with iOS7 and I have an issue with status bar. Basically the status bar appear over navigation bar like the image below:
I try to call in my viewDidLoad
self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = YES;
without success.
I have also added to the info.plist file UIViewControllerBasedStatusBarAppearance with no luck.
The main problem is that the application must be compatible with iOS6 and iOS7 and currently on iOS7 the view shifted 20px from the top.

edgesForExtendedLayout and automaticallyAdjustsScrollViewInsets are just standards for how parent view controllers lay out / manage the view. It looks like you're using a UINavigationBar, but not a UINavigationController, which means these properties won't do anything unless you code them to.
You can switch to use a UINavigationController, or you can programmatically change the height of your UINavigationBar from 44 to 64 on iOS 7.

Add an outlet to the UINavigationBar.
float currentVersion = 7.0;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion) {
// iOS 7
self.navBar.frame = CGRectMake(self.navBar.frame.origin.x, self.navBar.frame.origin.y, self.navBar.frame.size.width, 64);
}
You can also hide the status bar, this might be a better approach on these views to get more screen real estate.
I answered that here:
Position of navigation bar for modal view - iOS7

This is the biggest issue that comes with iOS 7 and there are many solutions to solve this but in my opinion, the best way to solve is to remove the navigation bar and embed your view controller in a navigation controller by going to Editor > Embed In Navigation Controller.

Add constraints top space to top layout guide

Related

IOS 7 Navigation bar overlapping Navigation bar

I had developed an app earlier for ios 4 and above, in which I had used 2 navigation bars on top. 1 was a global bar common for all the views and the other changed with the views.
In IOS 7 the main nav bar is overlapping the navigation bar of the views.
If I change the position or any other attribute of the navigation bars it renders the views blank.
Is there a way that I can have the view navigation bar below the main navigation bar like it appears in IOS 6?
Thanks in Advance
Moiz Ahmed Sulaiman
Did you try to set dgesForExtendedLayout for your VC:
self.edgesForExtendedLayout = UIRectEdgeNone;
or change your navigationBar translucent?
navigationBar.translucent = NO; // It is YES by default in iOS7.

iPhone hiding StatusBar shifts view down by 20 pix

I have a view laid out in the interface builder. Originally it used a StatusBar added to the top of the view in the interface builder. Now I decided to get rid of the status bar, but when I call
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
My view is still shifted down by 20 points. My guess is that my UINavigationController does not get the message and keeps my view in the old location.
Anyone else has an insight into what might be causing this issue?
I tried:
self.view.center = CGPointMake(self.view.center.x, self.view.center.y-21); This does not work.
I've tried:
self.view.center = CGPointMake(self.view.center.x, self.view.center.y-21);
This works, but leaves a black 20 px bar on the buttom before the tabbar.
How would I transition my view to a status-bar-less mode without having to manualy adjust all the views by 21px?
PS. The view is displayed perfectly if I remove the status bar in the app delegate before creating a UINavigationController for the view
You might want to call
[myViewController setWantsFullScreenLayout:YES];
That should allow it to take up the spare 20px.
Interface builder has a 'simulate user interface elements' option. Do you still have 'status bar' simulated? You need to deslect that option if your actual view doesn't show a status bar.

20px gap between top of ImageView and bottom of status bar after returning from iAd animation [duplicate]

What is the proper way to implement the status bar and navigation bar that go on top of an UIView?
alt text http://img.skitch.com/20081217-t78sdixk37hqgdh1ia2fgec4st.png
Just set “wants fullscreen layout” in your view controller. That solves the problem for me.
self.wantsFullScreenLayout = YES;
In the screenshot above, there's a translucent status bar and a translucent navigation bar.
The status bar is set using
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent];
The navigation bar is set using
theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
If you have a view controller inside a navigation controller, and you want to hide the status bar in order to have your viewController's view in full screen, you can always call :
[self.navigationController.view setNeedsLayout];
after hiding the status bar.
But I personally think
[self setWantsFullScreenLayout:YES];
is a better way.
The best way I came up was this: when using a "complex" hierarchy of Tab bar containing navigation controllers, with one "detail" view being a full screen view.
In the app delegate just before the tab bar controller's view is added to the window, I added this:
tabBarController.view.frame = [[UIScreen mainScreen] bounds];
This will make the tab bar controller cover the entire screen, even below the area of the status bar. I had to offset heights of several views to +20px, notably the navigation bars.
Set the statusbar style as black translucent and navigation bar style as black translucent. If you are using a navigation-based application, in the MainWindow.xib check the status bar is hidden and navigation bar is hidden checkboxes.
When the user touches the screen, start a timer to see if this was a single tap or double tap. If a single tap, make the statusbar and navbar hidden = NO. and once user activity stops, start a timer again. after some time of no activity, make them hidden again.
step 1 Set the UIViewControllerBasedStatusBarAppearance to No in the plist
Then add the following code in did finish launch option
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}
Please follow this code it worked for me

How to prevent view resizing/transform when UINavigationBar hides/shows

I have an application with a tab bar and a navigation bar. I push a view controller that is used to show photos, one at a time. It initially shows the bars and forward/back controls; after a delay, these hide, using setNavigationBarHidden:animated: and a custom transform (CGAffineTransformMakeTranslation) on the tab bar. This works, but the view controllers view , which shows the photo, leaps up and down. The same is true if I leave the tab bar out of the equation.
How can I prevent the UINavigationBar from moving my view around? I would like the photo to stay fixed in the screen, with the nav bar dropping down over the top segment of it.
Had this issue and fixed it with a class that inherited from UINavigationController
-(void)viewWillAppear:(BOOL)animated
{
self.navigationBar.translucent = YES;
}
Worked great for me, didn't had to set style to UIBarStyleBlackTranslucent. So it did kept my colors.
[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];
this seemed to do the trick for me!
I know this is an old question, but I accomplished that by disabling 'Autoresize Subviews' in Interface Builder
I haven't been able to find a proper way to handle this except to set the navigationBar style to translucent as in:
theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Other than creating another navigation bar and adding buttons to them, that's the best (and it seems to be what Apple does as well in it's Photo app)

How do I remove the UINavigationBar from a UIViewController?

I'm experimenting with the NavBar sample project for iPhone. When I tap on one of the rows in the table in the default view a new view slides in (so far so good). I want to remove the UINavigationBar bar at the top of the new view that slides in. How can I do this?
EDIT: I meant "UINavigationBar". Thanks to everyone who responded!
Are you referring to the status bar (where the time and battery status are shown) or the UINavigationBar (where the title and Back buttons are)?
To hide the status bar, use [UIApplication sharedApplication].statusBarHidden = YES; in your -applicationDidFinishLaunching: method.
To hide the UINavigationBar, you'll want to use the navigationBarHidden property of your UINavigationController.
You can either hide it programmatically by called setHidesStatusBar on your UIApplication (sharedApplication), or you can set it in the plist. Check the CrashLanding's plist.
[[UIApplication sharedApplication]setHidesStatusBar:YES];