Ios UITableView将数据传递到选项卡栏
我有一个UITableView,我需要将数据从表传递到一个选项卡栏,该选项卡栏在prepareForSegue函数中包含三个项目(3个viewController), 我可以参考选项卡栏的第一项和最后一项,如下所示:Ios UITableView将数据传递到选项卡栏,ios,Ios,我有一个UITableView,我需要将数据从表传递到一个选项卡栏,该选项卡栏在prepareForSegue函数中包含三个项目(3个viewController), 我可以参考选项卡栏的第一项和最后一项,如下所示: let desView: nextPageViewController = secondScene.viewControllers?.first as! nextPageViewController let desView2: next2ViewController =
let desView: nextPageViewController =
secondScene.viewControllers?.first as! nextPageViewController
let desView2: next2ViewController =
secondScene.viewControllers?.last as! next2ViewController
然后将数据传递给第一个和最后一个视图控制器,如下所示
if let indexPath = self.tableView.indexPathForSelectedRow {
let currentPhoto = sectionArray[indexPath.section][indexPath.row]
desView.currentPhoto = currentPhoto
desView2.currentPhoto = currentPhoto
问题是:如何引用中间的viewController,默认情况下选项卡栏有两个项目,我必须手动添加第三个项目,以便使用上述功能,我们只能引用第一个和最后一个项目。
是否有其他方法可以引用选项卡栏中的ViewController?您可以通过其索引访问阵列中的任何对象,如下所示:
secondScene.viewControllers[0]
secondScene.viewControllers[1]
secondScene.viewControllers[2]
etc非常感谢您的帮助。