Man*_*tas 9 iphone layout objective-c uiviewcontroller ios
我有UIView一个UIController观点.我的标准是320x460视图.在applicationDidFinishLaunching我这样做:
[window addSubview:[controller view]];
Run Code Online (Sandbox Code Playgroud)
奇怪的是,它UIView位于状态栏下(就像缺少出口一样).但是,如果我将iPhone旋转到一侧然后再回来,它会显示正常.
这是一种预期的行为(我打赌我可以通过设置偏移来修复它)或者我做错了吗?
Nic*_*anu 18
我通过presentModalViewController显示UIViewController时遇到了这个问题.
您可以通过在视图出现后手动调整控制器视图的大小来绕过它:
- (void) viewDidAppear: (BOOL) animated {
//manually adjust the frame of the main view to prevent it from appearing under the status bar.
UIApplication *app = [UIApplication sharedApplication];
if(!app.statusBarHidden) {
[self.view setFrame:CGRectMake(0.0,app.statusBarFrame.size.height, self.view.bounds.size.width, self.view.bounds.size.height - app.statusBarFrame.size.height)];
}
}
Run Code Online (Sandbox Code Playgroud)
小智 8
我认为您的问题是,当您向窗口添加视图时,您需要了解状态栏的状态并对其进行补偿:
if showing the status bar :
[controller view].frame = CGRectMake(0, **20**, 320, 460);
else
[controller view].frame = CGRectMake(0, 0, 320, **480**);
Run Code Online (Sandbox Code Playgroud)
这就是IB为您显示虚拟状态栏的原因.
| 归档时间: |
|
| 查看次数: |
20353 次 |
| 最近记录: |