gpt4 book ai didi

ios - UICollectionView 内部的 UITableView 处理触摸。

转载 作者:技术小花猫 更新时间:2023-10-29 11:15:10 25 4
gpt4 key购买 nike

Collection View 由一行水平对齐的单元格组成,其大小与 Collection View 的边界大小相同,单个单元格填满整个屏幕。

问题是 Collection View 似乎拦截了所有的平底锅。我怎样才能将它们转发到表格,以便我也可以垂直滚动表格。

我希望将垂直平移传送到单元格内的表格,以便它可以上下滚动。我希望将水平平移传送到 Collection View ,以便它可以水平滚动。

有什么想法吗?谢谢。

最佳答案

对于使用 storyBoard 的 CollectionView 中的 UITableView,请按照以下步骤操作:

-将 CollectionView 拖到 UIViewController,将数据源拖到 UIViewController(不要拖 delegate)。在 ViewController.m 中添加数据源方法

-创建 Cell:CollectionViewCell 类。为storyBoard中的Cell选择class为Cell类,指定reuse ID。

-将 tableView 拖入 collectionCell 方 block 内。委托(delegate),数据源也拖到 CollecionCell Square。添加 tableView 数据源,在 Cell.m 中委托(delegate)

-在其中实现 tableViewDidSelect 时创建 CellDelegate。将此委托(delegate)传递给 UIViewController 以执行其他操作

示例代码:https://github.com/lequysang/github_zip/blob/master/TableViewInCollection.zip

关于ios - UICollectionView 内部的 UITableView 处理触摸。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15192936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com