gpt4 book ai didi

iphone - 如何启动有关设备类型的特定 View

转载 作者:行者123 更新时间:2023-11-28 19:13:17 25 4
gpt4 key购买 nike

我正在尝试在启动时启动 3 个 View 中的 1 个。我要启动的 View 取决于设备类型。这是我目前在 AppDelegate.m

中的内容
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568.0) {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_Portrait5" bundle:nil];
}

else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 480.0) {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_Portrait4" bundle:nil];
}

else {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_PortraitPad" bundle:nil];
}
}

问题是,当我启动应用程序时,出现黑屏。

最佳答案

您没有在窗口上设置 Controller ,在该方法的末尾添加:

self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];

关于iphone - 如何启动有关设备类型的特定 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13779342/

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