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
基础教程推荐
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
