将新的viewcontroller链接到Storyboard? [英] Linking a new viewcontroller to Storyboard?
问题描述
可能有一个简单的解决方案,但我无法弄明白。
There is probably a simple solution but I can't figure it out.
我正在使用故事板作为界面。
I am using storyboards for the interface.
我从标签栏控制器开始,但在允许用户使用该应用程序之前,用户必须通过在开始时以模态方式推送的登录视图对自己进行身份验证。
I start with a tab bar controller, but before the user is allowed to use the app the user has to authenticate himself trough a loginview which is modally pushed at the start.
我想在同一个故事板上配置loginview,但我无法找到如何链接故事板上的视图控制器和我的代码。
I want to configure the loginview at the same storyboard, but I can't seam to figure out how to link the view controller at the storyboard and my code.
我做了什么:
- 创建一个新的UIViewController子类槽文件> new> new file 。
- 在故事板中拖动新的UIViewController
- 在自定义类标签中设置类
- 拖动UILabel进行测试。
- run
- Create a new UIViewController subclass trough file > new > new file.
- Drag a new UIViewController in the story board
- Set the class in the custom class tab
- drags a UILabel for test purpose.
- run
没有标签......
No label...
推荐答案
拉上一个新的UIViewController,它将作为登录视图控制器进入MainStoryboard。在属性检查器中,将标识符更改为LoginViewController(或适当的东西)。然后添加
Pull on a new UIViewController that will act as the login view controller onto the MainStoryboard. In the attribute inspector change the identifier to LoginViewController (or something appropriate). Then add
- (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];
}
到第一个视图控制器,登录屏幕将从你的故事板加载提出。
to the First view controller and the login screen will be loaded from your storyboard and presented.
希望这有帮助。
这篇关于将新的viewcontroller链接到Storyboard?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!