视图框架不会向下移动 20px(状态栏的高度)
view frame does not move down 20px (height of the statusbar)
我使用下面的代码来呈现 vViewController1
@property (retain,nonatomic) ViewController1 *vViewController1;
...
从 rootViewController 推送 vViewController1
[self.navigationController pushViewController:vViewController1 animated:NO];
Viewcontroller1 的 viewWillAppear
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
CGRect screen = [[UIScreen mainScreen] bounds];
if (self.navigationController) {
CGRect frame = self.navigationController.view.frame;
frame.origin.y = 20;
frame.size.height = screen.size.height - 20;
self.navigationController.view.frame = frame;
} else {
if ([self respondsToSelector: @selector(containerView)]) {
UIView *containerView = (UIView *)[self performSelector: @selector(containerView)];
CGRect frame = containerView.frame;
frame.origin.y = 20;
frame.size.height = screen.size.height - 20;
containerView.frame = frame;
} else {
CGRect frame = self.view.frame;
frame.origin.y = 20;
frame.size.height = screen.size.height - 20;
self.view.frame = frame;
}
}
}
}
但显示如下,并没有向下移动20px(状态栏高度)
欢迎您的评论
假设你没有使用自动布局(因为你正在玩框架尺寸)然后在情节提要中 select ViewController 然后转到尺寸检查器(小尺子)然后调整 Y视图的增量(根据您使用的模式更改为 20 或 -20 "View As")。
这可能会有所帮助 here 尽管我不确定 Y 中的 18 值我一直认为它是 20!
我使用下面的代码来呈现 vViewController1
@property (retain,nonatomic) ViewController1 *vViewController1;
...
从 rootViewController 推送 vViewController1
[self.navigationController pushViewController:vViewController1 animated:NO];
Viewcontroller1 的 viewWillAppear
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
CGRect screen = [[UIScreen mainScreen] bounds];
if (self.navigationController) {
CGRect frame = self.navigationController.view.frame;
frame.origin.y = 20;
frame.size.height = screen.size.height - 20;
self.navigationController.view.frame = frame;
} else {
if ([self respondsToSelector: @selector(containerView)]) {
UIView *containerView = (UIView *)[self performSelector: @selector(containerView)];
CGRect frame = containerView.frame;
frame.origin.y = 20;
frame.size.height = screen.size.height - 20;
containerView.frame = frame;
} else {
CGRect frame = self.view.frame;
frame.origin.y = 20;
frame.size.height = screen.size.height - 20;
self.view.frame = frame;
}
}
}
}
但显示如下,并没有向下移动20px(状态栏高度)
欢迎您的评论
假设你没有使用自动布局(因为你正在玩框架尺寸)然后在情节提要中 select ViewController 然后转到尺寸检查器(小尺子)然后调整 Y视图的增量(根据您使用的模式更改为 20 或 -20 "View As")。
这可能会有所帮助 here 尽管我不确定 Y 中的 18 值我一直认为它是 20!