【问题标题】:Start storyboard UIViewController from from UIController从 UIController 启动故事板 UIViewController
【发布时间】: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


    【解决方案1】:

    设法传递我必须使用的数据:

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

    而不是第一个视图控制器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 2018-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-24
      相关资源
      最近更新 更多