ios – 为iPhone 5加载不同的故事板@ app start

ios – 为iPhone 5加载不同的故事板@ app start,第1张

概述我在AppDelegate.m中使用以下代码来检测用户正在使用的设备: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceI 我在AppDelegate.m中使用以下代码来检测用户正在使用的设备:
- (BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    if(UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPhone)    {        CGSize result = [[UIScreen mainScreen] bounds].size;        if(result.height == 480)        {            NSLog(@"iPhone 3,5 Inch");            [UIStoryboard storyboarDWithname:@"MainStoryboard_iPhone" bundle:nil];        }        if(result.height == 568)        {            NSLog(@"iPhone 4 Inch");            [UIStoryboard storyboarDWithname:@"iPhone5-storyboard" bundle:nil];        }    }    return YES;}

但是当我构建应用程序时,会显示NSLog,但是没有Storyboard即将出现…

>部署信息中的主要故事板字段为空,以便代码决定要加载哪些内容…

有些可以帮我吗

Thx和来自德国的最好的问候

劳伦斯:)

解决方法 这是我现在在另一篇文章中发现的一种方式:
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)    {    // The iOS device = iPhone or iPod touch        CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;        UIVIEwController *initialVIEwController = nil;        if (iOSDeviceScreenSize.height == 480)        {   // iPhone 3GS,4,and 4S and iPod touch 3rd and 4th generation: 3.5 inch screen (diagonally measured)            // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone35            UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboarDWithname:@"Storyboard_iPhone35" bundle:nil];            // Instantiate the initial vIEw controller object from the storyboard            initialVIEwController = [iPhone35Storyboard instantiateInitialVIEwController];        }        if (iOSDeviceScreenSize.height == 568)        {   // iPhone 5 and iPod touch 5th generation: 4 inch screen (diagonally measured)            // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4            UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboarDWithname:@"Storyboard_iPhone4" bundle:nil];            // Instantiate the initial vIEw controller object from the storyboard            initialVIEwController = [iPhone4Storyboard instantiateInitialVIEwController];        }        // Instantiate a UIWindow object and initialize it with the screen size of the iOS device        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];        // Set the initial vIEw controller to be the root vIEw controller of the window object        self.window.rootVIEwController  = initialVIEwController;        // Set the window object to be the key window and show it        [self.window makeKeyAndVisible];    } else if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)    {   // The iOS device = iPad        UISplitVIEwController *splitVIEwController = (UISplitVIEwController *)self.window.rootVIEwController;        UINavigationController *navigationController = [splitVIEwController.vIEwControllers lastObject];        splitVIEwController.delegate = (ID)navigationController.topVIEwController;    }
总结

以上是内存溢出为你收集整理的ios – 为iPhone 5加载不同的故事板@ app start全部内容,希望文章能够帮你解决ios – 为iPhone 5加载不同的故事板@ app start所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1106820.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存