My app requires using instantiateViewControllerWithIdentifier - why?

谁都会走 提交于 2019-12-13 03:41:06

问题


I have added a Storyboard file to an app that initially had none. For some reason, I could not get my custom UIViewController to display correctly until I added this into didFinishLaunchingWithOptions:

ActivityViewController *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:NULL] instantiateViewControllerWithIdentifier:@"ActivityViewController"];

Why do I need to force the use of my storyboard like this? The iOS template projects (Single View, Master-Detail etc) doesn't need this.

Checklist:

  • Xcode Project Summary→Main Storyboard is set correctly to "MainStoryboard".
  • Interface Builder→Identity Inspector→Class is correctly set to "ActivityViewController".
  • Interface Builder→Identity Inspector→Storyboard ID is also set to "ActivityViewController", but this is only because it's needed by instantiateViewControllerWithIdentifier.

回答1:


You do not need to call instantiateViewControllerWithIdentifier if you set Is Initial View Controller on your "ActivetyViewController" in the storyboard. The initial view controller will have an arrow pointing at it.



来源:https://stackoverflow.com/questions/16618173/my-app-requires-using-instantiateviewcontrollerwithidentifier-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!