Background:
Since iOS7 release status bar is part of your the view. It is the common problem faced in application that navigation and status bar overlapped with your view content when you use nib or xib files.
XIB Actual result
I have seen in some application that to fix this problem view content is start from 64 pixel down. But it can raise other problem in the applications. So question is:
How To Fix This ?
Solution 1:
In View did load you can add the following line:
[self setEdgesForExtendedLayout:UIRectEdgeNone];
Example:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self setEdgesForExtendedLayout:UIRectEdgeNone];
}
edgesForExtendedLayout
This property tells which sides of your view can be extended to cover the whole screen. If you push a UIViewController into a UINavigationController, when the view of that view controller is laid out, it will start where the navigation bar ends, but this property will set which sides of the view (top, left, bottom, right) can be extended to fill the whole screen.
DefaultValue: UIRectEdgeAll (That is the reason your view is overlapping to Navigation bar and status bar. Because it try to cover whole screen).
UIRectEdgeNone: By this property we are specifying do not extend to any side. So it is fit.
Reference : Stackoverflow
Solution 2:
Set the translucent property of navigation bar of UINavigationController to No. By default it is "yes".
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:viewController];
navController.navigationBar.translucent = NO;
Comments
Post a Comment