内部的UITableViewCell UICollectionView如何设置的选择以从当前视图的数据传递到另一个

问题描述 投票:0回答:1

我有一个内含的tableview,在表视图我实现了一个集合视图与水平滚动视图控制器,数据显示正确,但我想转到另一个视图控制器,当我在传递一个字符串,该集合观察室点击看来,我该如何处理这个过程。提前致谢

ios swift uitableview uicollectionview uicollectionviewcell
1个回答
1
投票

你有两个选择

1)实施Collection视图视图控制器内委托&的数据源。你可以像cell.collectionview.datasource = self tableview中的cellForRowAt方法做到这一点

2)你可以创建委托/封盖从集合视图传递数据 - >的TableView细胞 - >的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
    }

实施或移动数据源和代表在您的视图控制器推或当前视图控制器要

© www.soinside.com 2019 - 2024. All rights reserved.