how to present a view controller on iOS7 without the status bar overlapping
The easiest workaround I've found is to wrap the view controller you want to present inside a navigation controller, and then present that navigation controller.
MyViewController *vc = [MyViewController new];UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];[self presentViewController:nav animated:YES completion:NULL];
Advantages:
- No mucking with frames needed.
- Same code works on iOS 6 an iOS 7.
- Less ugly than the other workarounds.
Disadvantages:
- You'll probably want to leave your XIB empty of navigation bars or toolbars, and programatically add UIBarButtonItems to the navigation bar. Fortunately this is pretty easy.
You need to add a Vertical Constraint from your top most view to Top Layout Guide as described in the following article by Apple.
https://developer.apple.com/library/ios/qa/qa1797/_index.html
Next code worked for me. Just put it to the controller which is presenting the new controller.
#pragma mark hidden status bar- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{ [[UIApplication sharedApplication] setStatusBarHidden:YES];}