Perform Segue on ViewDidLoad(在 ViewDidLoad 上执行 Segue)
问题描述
在 iOS 5 中,我有一个带有模式视图控制器的 Storyboard,如果它是用户第一次使用应用程序,我想显示它,之后我想跳过这个视图控制器.
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.
我设置了一个 NSDefault 键来处理这个问题,但是当我检查它是否已设置然后使用 performSegueWithIdentifier 启动 segue 时,没有任何反应.如果我把这个 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...
推荐答案
我回答了一个类似的问题,开发人员希望在开始时显示登录屏幕.我为他整理了一些示例代码,可以在这里下载.解决这个问题的关键是在正确的时间调用东西,如果你想显示这个新的视图控制器,你会在例子中看到你必须使用这样的东西
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];
}
我还对转场和故事板的工作原理进行了说明,您可以在此处
I also have an explanation of how segues and storyboards work that you can see here
这篇关于在 ViewDidLoad 上执行 Segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 ViewDidLoad 上执行 Segue
基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01