如上圖所示,如何裝載Storyboard中指定的ViewController?app
首先,須要指定ViewController的ID,如上圖右上方紅色方框內的Storyboard ID。而後使用下面的代碼:oop
- UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
- LeftViewController *leftController = [mainStoryboard instantiateViewControllerWithIdentifier:@"leftViewController"];
或者使用下面的代碼:
- UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
- ViewController *leftController = [mainStoryboard instantiateViewControllerWithIdentifier:@"leftViewController"];
- UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:leftController];