回答編集履歴
1
回答の追記
answer
CHANGED
@@ -5,4 +5,26 @@
|
|
5
5
|
let perfectVisibleCells = collectionView.visibleCells().filter {
|
6
6
|
return CGRectContainsRect(collectionView.bounds, $0.frame)
|
7
7
|
}
|
8
|
+
```
|
9
|
+
|
10
|
+
【追記】
|
11
|
+
cellの表示、非表示を捕捉するには、以下のメソッドを記述すればいけるかと思います。
|
12
|
+
|
13
|
+
cellの表示される時/非表示になる時のメソッドでの使用例を記述しておきます。
|
14
|
+
表示に関しては、iOS7以下だと動作しません。
|
15
|
+
|
16
|
+
```Swift
|
17
|
+
override func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
|
18
|
+
if let cell = cell as? HomeCollectionCell {
|
19
|
+
// do something
|
20
|
+
// cell.playVideo() // example.
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
override func collectionView(collectionView: UICollectionView, didEndDisplayingCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
|
25
|
+
if let cell = cell as? HomeCollectionCell {
|
26
|
+
// do something
|
27
|
+
// cell.stopVideo() // example.
|
28
|
+
}
|
29
|
+
}
|
8
30
|
```
|