Ios 由于未捕获异常而终止应用程序';NSInvalidArgumentException';,原因:';应用程序试图以模态方式呈现活动控制器

Ios 由于未捕获异常而终止应用程序';NSInvalidArgumentException';,原因:';应用程序试图以模态方式呈现活动控制器,ios,iphone,swift,Ios,Iphone,Swift,我正在尝试使用应用程序中已处于活动状态的视图控制器,我正在执行以下操作: if TabBar == nil { let storyboard = UIStoryboard(name: "Main", bundle: nil) TabBar = storyboard.instantiateViewControllerWithIdentifier("TabBar") as! UITabBarController self.presentViewCont

我正在尝试使用应用程序中已处于活动状态的视图控制器,我正在执行以下操作:

if TabBar == nil {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        TabBar = storyboard.instantiateViewControllerWithIdentifier("TabBar") as! UITabBarController
        self.presentViewController(TabBar!, animated: true, completion: nil)
    }
    else
    {
        self.presentViewController(TabBar!, animated: true, completion: nil)
    }
在“TabBar”视图控制器中,我有相同的方法

if(Queue == nil)
    {
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    Queue = storyboard.instantiateViewControllerWithIdentifier("Queue") as! UITableViewController
    self.presentViewController(Queue, animated: true, completion: nil)
    }

    else
    {
    self.presentViewController(Queue!, animated: true, completion: nil)
    }
这里一切都很好,但当我再次转到“TabBar”时,我得到了错误

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller

我知道我不能展示一个活动的控制器,但我不知道如何再次“使可见”“TabBar”视图控制器,知道吗?谢谢

你需要关闭你的viewcontroller,而不是在
队列
课上演示。我已经做了,它可以工作了,谢谢兄弟