【发布时间】:2016-12-02 15:35:35
【问题描述】:
我的数据由UITabBarController 的两个选项卡共享。第一个选项卡负责生成和更新第二个选项卡所使用的数据数组。
我原来在选项卡之间共享数据的方法奏效了。
------UIViewController
---UITabBarController
------UIViewController
使用上述方法,我从第一个选项卡中访问了数据数组:
let pointsViewController = self.tabBarController?.viewControllers?.first as! ShowPointsViewController
tableHeaders = pointsViewController.tableHeaders
ShowPointsViewController 是第一个标签
这是我的问题:
当我将我的第一个 UIViewController 嵌入到 UINavigationController 中,然后尝试使用下面的代码访问我的数据数组时,我收到运行时错误,因为 .first... 之后的代码返回为零。我知道我访问不正确,获得相同结果的正确方法是什么?
let pointsViewController = self.tabBarController?.viewControllers?.first?.navigationController?.topViewController as! ShowPointsViewController
【问题讨论】:
标签: ios uiviewcontroller swift3 uitabbarcontroller