現在表示されているcell自体は、__collectionView.visibleCells()__で取得できるので、
collectionView内に完全に表示されているcellを取得するならこんな感じでしょうか。
filter()の条件をひっくり返すか、__collectionView.visibleCells()から perfectVisibleCells__を除けば、完全に表示されていないcellも取得できるかと思います。
Swift
1 let perfectVisibleCells = collectionView.visibleCells().filter {
2 return CGRectContainsRect(collectionView.bounds, $0.frame)
3 }
【追記】
cellの表示、非表示を捕捉するには、以下のメソッドを記述すればいけるかと思います。
cellの表示される時/非表示になる時のメソッドでの使用例を記述しておきます。
表示に関しては、iOS7以下だと動作しません。
Swift
1 override func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
2 if let cell = cell as? HomeCollectionCell {
3 // do something
4 // cell.playVideo() // example.
5 }
6 }
7
8 override func collectionView(collectionView: UICollectionView, didEndDisplayingCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
9 if let cell = cell as? HomeCollectionCell {
10 // do something
11 // cell.stopVideo() // example.
12 }
13 }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/09/15 15:16
2015/09/16 00:57
2015/09/16 04:47
2015/09/16 05:18 編集
2015/09/16 14:21