ios - collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath 没有执行
问题描述
这是我的 collectionViewCell 图像。
我在collectionView
里面tableViewCell
,里面有一个按钮collectionViewCell
,可以按我的意愿完美工作。但令我困扰的是该函数didSelectItemAt
没有被调用。
我试过了
mycollectionview.isUserInteractionEnabled = true
mycollectionview.allowsSelection = true
但仍然无法正常工作。当我在某处阅读时,里面的按钮collectionViewCell
是它背后的原因。如果是这样,我该如何解决这个问题。
解决方案
请确认您已将委托设置UICollectionView
为您的 ViewController 而不是TableViewCell
. 如果您已将 Delegate 设置为UITableViewCell
,那么您didSelectItemAt
将在TableViewCell's
类内被调用
推荐阅读
- mysql - 使用 group by 汇总列并存储为 MySQL 中的新列(永久)
- python - Google Colab Latex 格式输出
- r - 用 R 计算字符串的矩阵
- javascript - 在 JavaScript 中用零替换字符串
- r - R重新排序许多列
- angular - 将时间戳转换为人类日期格式时,Angular 中的 DatePipe 不起作用
- amazon-web-services - 我的亚马逊教育账户的 CloudFront AWS 出现 403 错误
- python - Python - 将字典列表和键值转换为字符串
- c# - 尝试更新数组时指定的强制转换无效
- python - 海龟图形 onkeyrelease()