問題描述
在 iOS 5 中,我有一個帶有模式視圖控制器的 Storyboard,如果它是用戶第一次使用應(yīng)用程序,我想顯示它,之后我想跳過這個視圖控制器.
In iOS 5 I have a Storyboard with a modal view controller, that I would like to display if its the user's first time in the app, after that I would like to skip this view controller.
我設(shè)置了一個 NSDefault 鍵來處理這個問題,但是當(dāng)我檢查它是否已設(shè)置然后使用 performSegueWithIdentifier 啟動 segue 時,沒有任何反應(yīng).如果我把這個 segue 放在一個按鈕后面,它就可以正常工作......
I set an NSDefault key to handle this but when I check to see if this is set and then use performSegueWithIdentifier to initiate the segue, nothing happens. If i put this segue behind a button it works fine...
推薦答案
我回答了一個類似的問題,開發(fā)人員希望在開始時顯示登錄屏幕.我為他整理了一些示例代碼,可以在這里下載.解決這個問題的關(guān)鍵是在正確的時間調(diào)用東西,如果你想顯示這個新的視圖控制器,你會在例子中看到你必須使用這樣的東西
I answered a similar question where the developer wanted to show a login screen at the start. I put together some sample code for him that can be downloaded here. The key to solving this problem is calling things at the right time if you want to display this new view controller, you will see in the example you have to use something like this
- (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];
}
我還對轉(zhuǎn)場和故事板的工作原理進行了說明,您可以在此處
I also have an explanation of how segues and storyboards work that you can see here
這篇關(guān)于在 ViewDidLoad 上執(zhí)行 Segue的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!