Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView将数据传递到选项卡栏_Ios - Fatal编程技术网

Ios UITableView将数据传递到选项卡栏

Ios UITableView将数据传递到选项卡栏,ios,Ios,我有一个UITableView,我需要将数据从表传递到一个选项卡栏,该选项卡栏在prepareForSegue函数中包含三个项目(3个viewController), 我可以参考选项卡栏的第一项和最后一项,如下所示: let desView: nextPageViewController = secondScene.viewControllers?.first as! nextPageViewController let desView2: next2ViewController =

我有一个UITableView,我需要将数据从表传递到一个选项卡栏,该选项卡栏在prepareForSegue函数中包含三个项目(3个viewController), 我可以参考选项卡栏的第一项和最后一项,如下所示:

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

非常感谢您的帮助。