gpt4 book ai didi

ios - CollectionView didSelectItemAtIndexPath 不起作用 - Swift

转载 作者:行者123 更新时间:2023-11-28 06:09:52 25 4
gpt4 key购买 nike

我想使用 didSelectItemAtIndexPath 但它不起作用。

    collection_contactus.allowsSelection = true
collection_options.allowsSelection = true

collection_options!.dataSource = self
collection_options!.delegate = self

collection_contactus!.dataSource = self
collection_contactus!.delegate = self

func collectionView(_ collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("test")
// if(collectionView == collection_options)
// {
//
// }else{
// print("test: \(indexPath)")
// }
}

我看不到任何输出。

最佳答案

我认为您使用的是 Swift 3.2。该方法已重命名为 collectionView(_:didSelectItemAt:)在 Swift 3.0 中:

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
...
}

关于ios - CollectionView didSelectItemAtIndexPath 不起作用 - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47058912/

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