>选择国家
>接受T& Cs
从那里到家庭视图控制器.
我目前面临的问题是将第一个视图控制器从我的应用程序代理推送到屏幕上.我正在使用storyboards / Xcode 5 / iOS7
这是我提出的代码:
UINavigationController *navigationController = (UINavigationController *)self.window.rootVIEwController;UIStoryboard *mainStoryboard = [UIStoryboard storyboarDWithname:@"Main_iPhone" bundle: nil];BBCounterySettingsVIEwController *controller = (BBCounterySettingsVIEwController*)[mainStoryboard instantiateVIEwControllerWithIDentifIEr: @"CountrySettings"];[navigationController pushVIEwController:controller animated:NO];
问题是应用程序崩溃时遇到以下错误的最后一行代码:
* Terminating app due to uncaught exception ‘NSinvalidargumentexception’,reason: ‘-[UIVIEwController
pushVIEwController:animated:]: unrecognized selector sent to instance
0x8e9a400’
任何人有什么想法我做错了什么?
解决方法 你期待self.window.rootVIEwController是一个UINavigationController,但它是一个UIVIEwController.这意味着你的故事板中的最外面的视图控制器的类型是错误的.获取UINavigationController(在这种情况下应该工作)的更好的方法是在任何UIVIEwController上使用属性self.navigationController.
根据我的理解,您希望在用户第一次运行时让用户选择一些东西.你应该做的是呈现一个模态视图控制器,像这样:
- (BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions {//isFirstRun is some boolean you use to determine if it's the first runif(isFirstRun){ BBCounterySettingsVIEwController *controller = (BBCounterySettingsVIEwController *)[mainStoryboard instantiateVIEwControllerWithIDentifIEr: @"CountrySettings"]; [self.window.rootVIEwController presentVIEwController: controller animated:YES completion:nil];}总结
以上是内存溢出为你收集整理的ios – 通过AppDelegate以Storyboard方式实例化View Controller全部内容,希望文章能够帮你解决ios – 通过AppDelegate以Storyboard方式实例化View Controller所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)