2016-12-13 74 views
0

嗨,我有UIViewController。它有一些数组。 3秒后,我正在实例化故事板,并在故事板中找到第一个UIViewController,并为新的UIViewController设置数据。我的代码如下:从UIController开始故事板UIViewController

let storyBoard = UIStoryboard(name: "TabBar", bundle: nil) 
     let tabBarController = storyBoard.instantiateViewController(withIdentifier: "tab_bar_story") as! UITabBarController 

     let uiControllers:[UIViewController] = tabBarController.viewControllers! 

     print("Size \(uiControllers.count)") 

     var controller = uiControllers[0] as! UserTabBarItemViewController 
     controller.users = self.users 

//  self.present(controller, animated: true, completion: nil) 

当self.present行被取消注释时,我得到以下错误。

Size 2 
2016-12-13 23:53:16.684 swift_mvp[4229:87787] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <swift_mvp.ViewController: 0x7fb8eef02e20>.' 
*** First throw call stack: 

我的新故事板新tabBar有2个UIViewControllers我的意思是标签。有什么我在这里做worng。

回答

0

设法通过数据我不得不使用:

self.present(tabBarController, animated: true, completion: nil) 

代替的第一视图控制器。