gpt4 book ai didi

iphone - 仅在 iPad 上出现 "Application windows are expected to have a root view controller at the end of application launch"错误

转载 作者:太空狗 更新时间:2023-10-30 03:13:56 25 4
gpt4 key购买 nike

我正在尝试将我的 iPhone 专用应用程序转换为通用应用程序。我将设备切换到 Universal 并让 Xcode 为我制作一个 MainWindow-iPad.xib,现在当我在 iPhone 模拟器中运行该应用程序时它工作正常,但是当我在 iPad 模拟器中运行它时我得到一个白色屏幕和 Application windows expected to have a root view controller at the end of application launch 错误。我已经阅读了一些关于同样问题的其他帖子,但没有一篇只限于一台设备。

这是我的 application:didFinishLaunchWithOptions: 方法:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

/* some dropbox setup stuff */


// INIT VIEW AND CORE DATA
RootViewController *rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];

NSManagedObjectContext *context = [self managedObjectContext];
if (!context) {
// Handle the error.
}

rootViewController.managedObjectContext = context;

UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navigationController = aNavigationController;

[_window addSubview:[_navigationController view]];
[_window makeKeyAndVisible];

[rootViewController release];
[aNavigationController release];

return YES;
}

编辑:我只有一个 Root View Controller ,它的大小适合 iPhone,称为 RootViewController。但它仍然应该加载,不是吗?或者,如果不应该,我该如何为 iPad 创建一个?

最佳答案

更改以下行:

[_window addSubview:[_navigationController view]];

到:

_window.rootViewController = _navigationController;

或者,如果您需要 iOS 3 兼容性:

if ([_window respondsToSelector:@selector(setRootViewController:)]) {
_window.rootViewController = _navigationController;
} else {
[_window addSubview:_navigationController.view];
}

关于iphone - 仅在 iPad 上出现 "Application windows are expected to have a root view controller at the end of application launch"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8706828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com