![](/img/trans.png)
[英]collectionView didSelectItemAt indexPath not called swift
[英]Swift 2.3 IndexPath error in CollectionView
嗨,我是iOS的新手,很快。 我最近切換到Swift 2.3,現在卻遇到此錯誤
Use of undeclared type 'IndexPath'
對於這種方法
override func collectionView(collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
有任何想法嗎??
函數參數應該是NSIndexPath
而不是IndexPath
。 Xcode 8+使用Swift 3.0
的文檔和代碼完成。
Swift 2.3語法:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
Swift 3.0語法:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath)
對! 在Apple文檔中,這是錯誤的。 不知道為什么他們不只是解決它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.