I am migrating my application to iOS 7. For handing the status bar issue I have added this code
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f)
{
CGRect frame = self.navigationController.view.frame;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
frame.origin.y = 20;
}
else
{
frame.origin.x = 20;
}
[self.navigationController.view setFrame:frame];
}
This is working fine in normal case. If I am changing orientation (app supports only landscape orientation) or presenting any view controller and dismissing model view controller my view controller alignment changed. The status bar again overlaps my view controller. This piece of code is not working at all. Please guide me to fix this status bar issue.
Case 2: This is how I am presenting my view controller
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
reader.supportedOrientationsMask = ZBarOrientationMaskLandscape;
else
reader.supportedOrientationsMask = ZBarOrientationMaskPortrait;
[self presentModalViewController:reader animated:YES];
Ref:
Thanks in advance.
set the following to info.plist
View controller-based status bar appearance = NO;
MUCH MUCH MUCH simpler answer:
Align the top of your view to the "top layout guide", but control-dragging "Top Layout Guide" to your view and setting the "vertical" constraint. See this answer for a picture reference.
The way it works is - the "Top Layout Guide" will automagically ajust itself for when the status bar is or is not there, and it will all work - no coding required!
P.S. In this particular example, the background showing through at the bottom should also be resolved by setting an appropriate vertical constraint of the view's bottom, to it's superview, or whatever...
There are several different ways. One approach is to use .plist file
This will hide status bar throughout project.
Hear we can do this for all views at once
And While we are using orientation we can add below method in app delegate to set it via orientation.
You should Add below navigation controller category for it
.h
.m
To hide status bar in ios7 follow these simple steps :
In Xcode goto "
Resources
" folder and open "(app name)-Info.plist file
".View controller based status bar appearance
" key and set its value "NO
"Status bar is initially hidden
" key and set its value "YES
"If the keys are not there then you can add it by selecting "
information property list
" at top and click + iconI am late for this Answer, but i just want to share what i did, which is basically
the easiest solution
First of all-> Go to your
info.plist File
and add Status Bar Style->Transparent Black Style(Alpha of 0.5)Now ,here it Goes:-
Add this code in your AppDelegate.m