【发布时间】:2017-04-28 22:22:21
【问题描述】:
嗨,我有 UIViewController。它有一些数组。 3 秒后,我正在实例化情节提要并在情节提要中找到第一个 UIViewController 并将我的数据设置为新的 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:
我在新 Storyboard 中的新 tabBar 有 2 个 UIViewController,我的意思是标签。有什么我正在做的事情吗?
【问题讨论】:
标签: xcode swift3 uitabbarcontroller uistoryboard