Ant*_*ton 7 objective-c uinavigationcontroller ios
I am trying present ViewController I have created with StoryBoards:
AuthViewController *authViewController = [[AuthViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:authViewController];
UIViewController *vc = [[[[UIApplication sharedApplication] windows] firstObject] rootViewController];
[vc presentViewController:nav animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
But getting it with black screen. What could be the issue?
Kam*_*pai 13
Alloc init AuthViewController并不意味着将为控制器创建视图布局.
这里视图控制器没有加载它的视图,这就是你得到黑屏的原因.使用storyboard对象和视图控制器的标识符来加载其视图.
在AuthViewController控制器的Storyboard中指定故事板标识符.
添加Storyboard ID并标记true为Use Storyboard ID像下面的图像的选项:

现在AuthViewController使用以下代码获取控制器对象:
AuthViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"AuthViewController"];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5516 次 |
| 最近记录: |