ios - 如何在 Swift 中获取 UICollectionViewCell 中 UISwitch 的位置

标签 ios swift uicollectionview uicollectionviewcell uiswitch

我有一个 UICollectionView 和一个 UIImageView 和一个 UISwitch。单击 UISwitch 时,我想检索 Cell 的索引。

我可以在单击单元格中的 UIImageView 时检索单元格的索引,但不能使用 didSelectItemAtIndexPath 检索开关。

我们将不胜感激。

最佳答案

切换UISwitch时单元格不会被选中,因此必须使用其他方式来识别该项目。

通常这是通过以下方式完成的:

  • 为交换机使用专用目标
  • 或使用标签来识别开关

关于ios - 如何在 Swift 中获取 UICollectionViewCell 中 UISwitch 的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38367055/

相关文章:

ios - UICollectionViewCell 选择时双倍大小

ios - UITableViewCell 中的 UICollectionView 在 iOS 中无法正常工作

ios - 是否可以在 NSAttributedString 中混合不同的对齐方式?

ios - UICollectionView - 如何设置行的背景颜色

ios - 如何在 Swift 中的 WkWebView 中设置 Cookie?

uiviewcontroller - Swift presentViewController 没有导航栏

ios - 添加搜索栏以过滤 Collection View

ios - 在运行时动态实现委托(delegate)

ios - ID3 通过音频流?

SwiftUI 多行文本背景颜色