0

在 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 上。

4

1 回答 1

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];
    }
于 2013-02-16T03:29:31.903 回答