[英]didSelectItemAtIndexPath Doesn't Work In Collection View Swift
[英]CollectionView didSelectItemAtIndexPath doesn't work - Swift
我想使用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。 該方法在 Swift 3.0 中被重命名為collectionView(_:didSelectItemAt:)
:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.