2016-12-13 84 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) 

代替的第一視圖控制器。