問題描述
可能有一個簡單的解決方案,但我想不通.
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.
我想在同一個故事板上配置登錄視圖,但我無法弄清楚如何將故事板上的視圖控制器和我的代碼鏈接起來.
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 子類槽文件 > 新建 > 新文件.
- 在故事板中拖動一個新的 UIViewController
- 在自定義類選項卡中設置類
- 拖動 UILabel 進行測試.
- 運行
沒有標簽...
推薦答案
拉上一個新的 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.
希望這會有所幫助.
這篇關于將新的視圖控制器鏈接到情節提要?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!