问题描述
|
我正在使用下面的代码来测试问题。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *controller = [[UIViewController alloc] init];
controller.view.backgroundColor = [UIColor whiteColor];
[window setRootViewController:controller];
UIViewController *controller2 = [[UIViewController alloc] init];
[controller.view addSubview:controller2.view];
controller2.view.backgroundColor = [UIColor yellowColor];
UIViewController *controller3 = [[UIViewController alloc] init];
controller3.view.backgroundColor = [UIColor purpleColor];
[controller2.view addSubview:controller3.view];
[window makeKeyAndVisible];
return YES;
}
当我在模拟器或iPhone上运行它们时,会出现
图片
我很困惑,因为这个问题发生在我的项目中,但是当我使用系统的照片选择器时,它会正确显示。
所以,谁能帮助我,非常感谢。
解决方法
默认情况下,
UIViewController
\的view
使用the3ѭ值作为其框架。这通常会显示状态栏,为(0,20,320,460)
。因此,当您分层添加视图时,您会发现视图向下推。