我有一个内部带有tableview的视图控制器,在该表视图中,我实现了带有水平滚动的集合视图,数据正确显示,但是当我单击传递视图的集合视图单元格时,我想转到另一个视图控制器到该视图的字符串,我该如何处理此过程。 预先感谢
答案 0 :(得分:1)
您有两种选择
1)在视图控制器内部实现Collection视图委托和数据源。您可以在表视图的cellForRowAt方法(如cell.collectionview.datasource = self
2)您可以创建委托/闭包以从Collection View-> TableView Cell-> UIViewController
传递数据希望对您有所帮助,并且让我知道您是否需要示例
示例
由于您在理论上难以理解,因此这里是示例
假设在您的视图控制器中
您具有tableview数据源,如下所示
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier:"identifer", for: indexPath) as! YourTableViewCell
// You have collection view inside tableview cell so
cell.yourCollectionViewObject.dataSource = self
cell.yourCollectionViewObject.delegate = self
return cell
}
在您的View Controller中实现或移动数据源和代理,并推送或呈现您想要的View Controller