在打开多任务栏之前看不可见 - iPhone

时间:2013-02-16 03:00:08

标签: iphone objective-c

我在iPhone 3.5英寸显示屏ios 5.1上运行时首次出现自动布局崩溃 - 通过关闭自动布局来修复此问题。但是,现在,当我运行应用程序时,屏幕是黑色的。仅当我双击主页按钮以唤起多任务栏时,才能看到该视图。很奇怪,对吗?

在应用启动时:

enter image description here

唤起多任务处理。

enter image description here

代码段:

   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上不会发生这种情况。

1 个答案:

答案 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];
    }