我在iPhone 3.5英寸显示屏ios 5.1上运行时首次出现自动布局崩溃 - 通过关闭自动布局来修复此问题。但是,现在,当我运行应用程序时,屏幕是黑色的。仅当我双击主页按钮以唤起多任务栏时,才能看到该视图。很奇怪,对吗?
在应用启动时:
唤起多任务处理。
代码段:
if(screenSize.height == 480) {
// iPhone Classic
welcomeViewController = [welcomeViewController initWithNibName:@"WelcomeViewController~iphone3.5" bundle:nil];
viewController = [viewController initWithNibName:@"selectZone~iphone3.5" bundle:nil];
fixtureViewController = [fixtureViewController initWithNibName:@"fixture~iphone3.5" bundle:nil];
[windowOldiPhone addSubview:fixtureViewController.view];
[windowOldiPhone addSubview:viewController.view];
[windowOldiPhone addSubview:welcomeViewController.view];
[windowOldiPhone makeKeyAndVisible];
[windowOldiPhone bringSubviewToFront:welcomeViewController.view];
}
注意:在运行iOS 6的iPhone / iPad上不会发生这种情况。
答案 0 :(得分:0)
在致电bringSubviewToFront
之前致电makeKeyAndVisible
。如下所示
if(screenSize.height == 480) {
// iPhone Classic
welcomeViewController = [welcomeViewController initWithNibName:@"WelcomeViewController~iphone3.5" bundle:nil];
viewController = [viewController initWithNibName:@"selectZone~iphone3.5" bundle:nil];
fixtureViewController = [fixtureViewController initWithNibName:@"fixture~iphone3.5" bundle:nil];
[windowOldiPhone addSubview:fixtureViewController.view];
[windowOldiPhone addSubview:viewController.view];
[windowOldiPhone addSubview:welcomeViewController.view];
[windowOldiPhone bringSubviewToFront:welcomeViewController.view];
[windowOldiPhone makeKeyAndVisible];
}