0
在我的代碼中,我目前有一個嵌入故事板參考的容器視圖。我引用的故事板包含一個視圖控制器,其中包含兩個容器視圖。如何從另一個容器視圖訪問容器視圖?
在我與容器視圖視圖控制器,我訪問我的容器視圖的視圖控制器,像這樣:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
if segue.identifier == "showMetric" {
guard let metricChildViewController = segue.destinationViewController as? MetricChildViewController else { return }
var delegate: NewMetricDelegate!
let type = MetricsType.watts
let activityDelegate = NewActivityMetricDelegate(data: self.dataSet.dailySummary)
activityDelegate.dailySummaryPresentationDelegate = metricChildViewController
delegate = activityDelegate
metricChildViewController.metricDelegate = delegate
metricChildViewController.configure(type)
//I want to gain access to the table view controller
}
}
這裏我創建MetricChildViewController,是嵌入在我的容器視圖控制器的一個實例視圖。就像我之前說過的,MetricChildViewController包含兩個容器視圖。我試圖配置它的表視圖控制器。
我想要做的是在我的視圖控制器中的prepareForSegue方法中包含一個prepareForSegue,以訪問我的容器視圖的viewController的容器視圖,如果有意義的話。
這似乎不是最好的方式去實現它,所以我想知道我應該如何去做這件事。