【问题标题】:ios 6 iPhone window.rootViewController crashesios 6 iPhone window.rootViewController 崩溃
【发布时间】:2013-02-18 15:18:10
【问题描述】:

我的应用在 iPad 和 iPhone 上都可以在 iOS 5.1 上正常运行。在 iOS 6 中,应用程序在 iPad 上运行良好,但在设置 window.rootViewController = navigationViewController 时在 iPhone 中崩溃。我在application didFinishLaunchingWithOptions 的这段代码处设置了异常断点来停止执行。我什至尝试将其添加为[window addSubView:navigationViewController.view],但没有运气。有没有人遇到过类似的问题。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{
     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
     rootViewController = [[SpringboardViewController alloc] initWithNibName:@"SpringboardViewController" bundle:nil];   
     UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootViewController];

    self.window.rootViewController = nav;
    self.window makeKeyAndVisible];
    return YES;
}

【问题讨论】:

  • 你能在代码中发布 didFinishLaunchingWithOptions 方法吗
  • 这完全适用于 iPhone 和 iPad ios 5.1 也适用于 ios 6.0 iPad 问题仅适用于 iPhone 6.0。我已经粘贴了上面的代码。调试器停止在 self.window.rootViewController = nav ; 没有任何错误日志。它只是在控制台中打印 lldb

标签: ios uiwindow


【解决方案1】:

【讨论】:

  • ogres 感谢您的回复,但我的应用程序在 5.1 上运行良好,问题仅适用于 iPhone 6.0,也没有错误显示以提供有关我的问题的更多信息。
【解决方案2】:

感谢您的回复,我发现了问题,问题出在application supportedInterfaceOrientationsForWindow,我返回UIInterfaceOrientationPortrait而不是UIInterfaceOrientationMaskPortrait,因为应用程序调试器在self.window.rootViewController = nav,我认为这句话有问题。

感谢拉文达兰和食人魔。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多