【问题标题】:PresentModalViewController overlaps the navigation bar and status bar iOS 7PresentModalViewController 重叠导航栏和状态栏 iOS 7
【发布时间】:2014-09-26 11:13:43
【问题描述】:
我解决了所有视图中的导航栏状态栏问题,但是当我使用 presentModalViewController 显示另一个视图时,导航栏和状态栏再次重叠。我正在使用它来呈现新视图:
[self.parentViewController presentModalViewController:newController animated:YES];
知道为什么会这样吗?
【问题讨论】:
标签:
ios7
xcode5.1
uimodalpresentationstyle
【解决方案1】:
试试这个代码
1.你的视图控制器
UIViewController *View=[[UIViewController alloc]init];
2.如果您需要导航栏添加此代码
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:View];
nav.modalPresentationStyle=UIModalPresentationFormSheet;(presentingModal view)
[self presentViewController:nav animated:YES completion:nil];
【解决方案2】:
对我来说,它的工作原理是
将导航栏和其他视图推 20 像素,以获得我作为模态视图控制器呈现的视图
-
在viewDidload中设置状态栏的黑色背景:
UIView *statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024, 20)];
statusBarView.backgroundColor = [UIColor blackColor];
[self.view addSubview:statusBarView];