故事板Segue没有加载视图

时间:2012-06-26 20:33:20

标签: objective-c ios uistoryboard

我正在尝试代码中的代码。 prepareForSegue函数运行并显示正确的目标视图控制器,但没有任何反应。关于我缺少什么或我配置错误的任何内容?

查看控制器可能路径:

A ->B (sgueResultat)
or
A->C (sgueStopSplash)

选择segue的代码:

if (proversion)
    [self performSegueWithIdentifier:@"sgueResultat" sender:self];

}
else {
    [self performSegueWithIdentifier:@"sgueStopSplash" sender:self];

}

`

我可以确认的prepareForSegue是由NSLog运行的:

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
 NSLog(@"Source Controller = %@", [segue sourceViewController]);
 NSLog(@"Destination Controller = %@", [segue destinationViewController]);
 NSLog(@"Segue Identifier = %@", [segue identifier]);

Nslog输出:

2012-06-26 22:22:26.002 ClosetV2[2333:fb03] Source Controller = <ABStartViewController: 0xeb12270>
2012-06-26 22:22:26.002 ClosetV2[2333:fb03] Destination Controller = <SplashAfterStopViewController: 0x6b2c9e0>
2012-06-26 22:22:26.003 ClosetV2[2333:fb03] Segue Identifier = sgueStopSplash
2012-06-26 22:22:26.003 ClosetV2[2333:fb03] sgueStopSplash

此致 安德烈亚斯

1 个答案:

答案 0 :(得分:0)

确保在故事板中将您的segues设置为“modal”(如果您喜欢,则自定义)。

我记得当我第一次开始使用segues时,我会继续尝试使用push,只有你有嵌入式UINavigationController才能使用push。否则,推送segue将无法正常工作。

另一个想法......下面的代码执行在哪里?如果动画已经发生或者当前视图尚未显示在屏幕上,则它将无法正常工作。例如,如果在viewDidLoad中有此代码,则无法使用。

if (proversion)
    [self performSegueWithIdentifier:@"sgueResultat" sender:self];

}
else {
    [self performSegueWithIdentifier:@"sgueStopSplash" sender:self];

}

编辑:更新的答案

在执行你的segue之前等待[self dismissModalViewController:YES]动画完成实际上很烦人且有点乱。我不认为有一种“适当”的方式来做到这一点。但是,如果将以下方法放在具有模态控制器的视图中并在使用[self dismissModalViewController:YES]后发送消息,则应该处于良好状态。

- (void)waitUntilModalControllerIsDismissed
{
    if(self.modalViewController)
    {
        [self performSelector:@selector(waitUntilModalControllerIsDismissed:)
                   withObject:nil 
                   afterDelay:0.1f];
        return;
    }
    else
    {
        //At this point, the modal animation will be completed and you can perform your segue if you want
    }  

}