gpt4 book ai didi

ios - swift UICollectionView : didSelectItemAtIndexPath not responding

转载 作者:行者123 更新时间:2023-11-28 12:40:07 25 4
gpt4 key购买 nike

我在 ViewController 中有 UICollection View ,它根本不响应 didSelectItemAtIndexPath。

// super class
class ViewController: UIViewController, iCarouselDelegate, iCarouselDataSource, UICollectionViewDelegate, UICollectionViewDataSource {

@IBOutlet weak var collectionView: UICollectionView!


// delegate
override func viewDidLoad() {
super.viewDidLoad()

// collection view delegate and datasource
collectionView.delegate = self
collectionView.dataSource = self


// did select item
func collectionView(collectionView: UICollectionView!, didSelectItemAtIndexPath indexPath: NSIndexPath!) {

print(indexPath)

}

还有这位来自 IB 的代表。 UiCollectionView delegate in IB

最佳答案

一些猜测可能会有帮助:

  • 您是否不小心覆盖了 - (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath

  • 确保将 collectionView.userInteractionEnabled 设置为 true

  • 如果一些高优先级的UIResponderUIGestureRecognizerUIButton被添加到单元格或者它的 subview ,相应的方法应该被调用

关于ios - swift UICollectionView : didSelectItemAtIndexPath not responding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39651338/

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