我想使用 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/