Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Status bar appear over my view's bounds in iOS 7 [duplicate]

I tried to test my app in iOS 7, and then I find my view appears over the status bar... As I read, in iOS 7, the status bar is hidden. So how do I make it compatible to run both in iOS 6 and iOS 7? Should I have to make different .xib files for different iOS versions for each screen?

I have been going through reading this: If both versions of a standard app should have a similar layout, use Auto Layout to create a UI that works correctly in both versions of iOS. To support multiple versions of iOS, specify a single set of constraints that Auto Layout can use to adjust the views and controls in the storyboard or XIB files (to learn more about constraints, see “Constraints Express Relationships Between Views”).

If both versions of a standard app should have a similar layout, and you’re not using Auto Layout, use offsets. To use offsets, first update the UI for iOS 7. Next, specify values that define the origin, height, and width of each element in the earlier UI as offsets from the element’s new position in the iOS 7 UI.

But when I use autolayout in .xib, it shows an error that autolayout is in a prior version to iOS 6.

How do I fix this problem?

like image 752
Bhrigesh Avatar asked Aug 22 '13 09:08

Bhrigesh


People also ask

How do I get rid of the status bar on my iPhone?

To completely hide it on the home screen, open up an app, such as Settings, and wait about three to four seconds. Press the home button again, and the status bar will be completely gone. The status bar will only be hidden on your home screen, so you'll still see it while using apps.

What is status bar in IOS?

A status bar appears along the upper edge of the screen and displays information about the device's current state, like the time, cellular carrier, and battery level.

How do I show the status bar on my iPhone?

How To Fix A Missing iPhone Status Bar. 99% of the time, restarting your iPhone will fix this problem. On an iPhone 8 or earlier, press and hold the power button until the words “slide to power off” appear on the display. Then, swipe the power icon from left to right to turn off your iPhone.


2 Answers

iOS 7 apparently supports the Status Bar being hidden for some views but not others. To hide it for all views, do the following:

  1. Make sure Hide during application launch is still checked, to support previous OS versions.
  2. In your Info.plist file, add View controller-based status bar appearance and set it to NO.
  3. You may need to "Clean" before building, (I did), but then your app should work as before: no status bar hanging over your views!
like image 150
Nerrolken Avatar answered Sep 17 '22 18:09

Nerrolken


You probably need to add the following code on each view controller.

- (void)viewDidLoad {     [super viewDidLoad];     if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)])     {         [self prefersStatusBarHidden];         [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];     }     else     {         // iOS 6         [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];     } }  // Add this method - (BOOL)prefersStatusBarHidden {     return YES; } 
like image 27
NIKHIL Avatar answered Sep 21 '22 18:09

NIKHIL