应用程序尝试以模态形式显示活动控制器ios [英] Application tried to present modally an active controller ios

查看:61
本文介绍了应用程序尝试以模态形式显示活动控制器ios的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用父视图控制器设置ViewController,直到显示它可以提供回调,我使用PrepareForSegue

I was trying to set the ViewController with a parent view controller before it shows show that it can provide call backs, I done this using PrepareForSegue

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"newQuarter"])
    {
        [segue.destinationViewController setParentViewController:self];
    }
}

它崩溃了,给我错误消息:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller.

It crashed giving me the error message: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller.

所以我尝试使用另一种方法,并在触摸按钮时设置了新的视图控制器,

So I tried using another method and set up a new view controller on the button touches up,

- (IBAction) buttonClicked
{
    NewViewController *newController = [[NewViewController alloc] init];
    [newController setParentViewController:self];

    [self presentViewController:newController animated:YES completion:nil];
}

但是没有运气,它仍然给我同样的错误消息,任何人都可以请教吗?谢谢!

but with no luck it is still giving me the same error message, can anyone please advice? Thanks!

推荐答案

已解决了该问题,因为父视图控制器是tableViewController,它已嵌入在navigationViewContoller中.这就是为什么应该推举segue而不是执行模式转换的原因.

Resolved the problem, since the parent view controller is a tableViewController, which it was embedded in a navigationViewContoller. That's why the segue should be pushed rather then performing modal transition.

这篇关于应用程序尝试以模态形式显示活动控制器ios的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆