Jus*_*tin 28 xcode interface-builder uiviewcontroller ios ios5
可能有一个简单的解决方案,但我无法弄清楚.
我正在使用故事板作为界面.
我从一个标签栏控制器开始,但在允许用户使用该应用程序之前,用户必须通过在开始时以模态方式推送的登录视图来验证自己.
我想在同一个故事板上配置loginview,但我无法找到如何链接故事板上的视图控制器和我的代码.
我做了什么:
无标签...
Sco*_*ood 40
拉上一个新的UIViewController,它将作为MainStoryboard上的登录视图控制器.在属性检查器中,将标识符更改为LoginViewController(或适当的内容).然后加
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:vc animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
到第一个视图控制器和登录屏幕将从故事板加载并显示.
希望这可以帮助.
小智 6
以上Scott Sherwood的答案是经过大量搜索后找到的最正确的答案.虽然根据新的SDK(6.1)进行了微小的更改,但presentModalViewController显示已弃用.
以上是对上述答案的极小变化.
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
HomeViewController * hvc = [sb instantiateViewControllerWithIdentifier:@"LoginView"];
[hvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:hvc animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
42321 次 |
| 最近记录: |