栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用情节提要以编程方式设置初始视图控制器

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用情节提要以编程方式设置初始视图控制器

如何 使用虚拟初始视图控制器

确保所有初始视图控制器都有一个Storyboard ID。

在情节提要中,取消选中第一个视图控制器中的“是初始视图控制器”属性。

如果您此时运行应用程序,则将阅读:

Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set?

您会注意到,应用程序委托中的window属性现在为nil。

在应用程序的设置中,转到目标和

Info
选项卡。有明确的价值
Main storyboard file basename
。在
General
标签上,清除的值
Main Interface
。这将删除警告。

在应用程序委托的

application:didFinishLaunchingWithOptions:
方法中创建窗口和所需的初始视图控制器:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    self.window = [[UIWindow alloc] initWithframe:UIScreen.mainScreen.bounds];    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];    UIViewController *viewController = // determine the initial view controller here and instantiate it with [storyboard instantiateViewControllerWithIdentifier:<storyboard id>];    self.window.rootViewController = viewController;    [self.window makeKeyAndVisible];    return YES;}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/668801.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号