ios Storyboard doesn't contain a view controller with identifier
【问题现象】
创建自定义storyboard,添加ViewController之后通过instantiateViewControllerWithIdentifier方法创建ViewController异常。
【问题分析】
原始代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor redColor];
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Window" bundle:nil];
CTestViewController *t = [storyBoard instantiateViewControllerWithIdentifier:@"CTestViewController"];
[self.window setRootViewController:t];
[self.window makeKeyAndVisible];
return YES;
}
如果创建Singal View Application,则正常。
发现storyboard文件名不能为Window.storyboard,改为其它文件名即可。