Skip to content

Commit d42d494

Browse files
committed
Updated: README, Example
1 parent 496eaaf commit d42d494

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

Example/Example/Pattern1ViewController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ final class Pattern1ViewController: UIViewController {
3737

3838
// MARK: - InfiniteCollectionViewDataSource, InfiniteCollectionViewDelegate
3939
extension Pattern1ViewController: InfiniteCollectionViewDataSource, InfiniteCollectionViewDelegate {
40-
public func number(ofItems collectionView: UICollectionView) -> Int {
40+
func number(ofItems collectionView: UICollectionView) -> Int {
4141
return items.count
4242
}
4343
func collectionView(_ collectionView: UICollectionView, dequeueForItemAt dequeueIndexPath: IndexPath, cellForItemAt usableIndexPath: IndexPath) -> UICollectionViewCell {
4444
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ImageCollectionViewCell.identifier, for: dequeueIndexPath) as! ImageCollectionViewCell
4545
cell.configure(dequeueIndexPath: usableIndexPath)
4646
return cell
4747
}
48+
func infiniteCollectionView(_ collectionView: UICollectionView, didSelectItemAt usableIndexPath: IndexPath) {
49+
print("didSelectItemAt: \(usableIndexPath.item)")
50+
}
4851
func scrollView(_ scrollView: UIScrollView, pageIndex: Int) {
4952
pageControl.currentPage = pageIndex
5053
}

Example/Example/Pattern2ViewController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,7 @@ extension Infinite2TableViewCell: InfiniteCollectionViewDataSource, InfiniteColl
119119
cell.configure(dequeueIndexPath: usableIndexPath)
120120
return cell
121121
}
122+
func infiniteCollectionView(_ collectionView: UICollectionView, didSelectItemAt usableIndexPath: IndexPath) {
123+
print("didSelectItemAt: \(usableIndexPath.item)")
124+
}
122125
}

InfiniteCollectionView/InfiniteCollectionView.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@
88

99
import UIKit
1010

11-
public protocol InfiniteCollectionViewDataSource: class {
11+
@objc public protocol InfiniteCollectionViewDataSource: class {
12+
@objc @available(*, deprecated, renamed: "number(ofItems:)")
13+
optional func numberOfItems(collectionView: UICollectionView) -> Int
14+
@objc @available(*, deprecated, renamed: "collectionView(_:dequeueForItemAt:cellForItemAt:)")
15+
optional func cellForItemAtIndexPath(collectionView: UICollectionView, dequeueIndexPath: NSIndexPath, indexPath: NSIndexPath) -> UICollectionViewCell
1216
func number(ofItems collectionView: UICollectionView) -> Int
1317
func collectionView(_ collectionView: UICollectionView, dequeueForItemAt dequeueIndexPath: IndexPath, cellForItemAt usableIndexPath: IndexPath) -> UICollectionViewCell
1418
}
1519

1620
@objc public protocol InfiniteCollectionViewDelegate: class {
21+
@objc @available(*, deprecated, renamed: "infiniteCollectionView(_:didSelectItemAt:)")
22+
optional func didSelectCellAtIndexPath(collectionView: UICollectionView, indexPath: NSIndexPath)
23+
@objc @available(*, deprecated, renamed: "scrollView(_:pageIndex:)")
24+
optional func didUpdatePageIndex(index: Int)
1725
@objc optional func infiniteCollectionView(_ collectionView: UICollectionView, didSelectItemAt usableIndexPath: IndexPath)
1826
@objc optional func scrollView(_ scrollView: UIScrollView, pageIndex: Int)
1927
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func number(ofItems collectionView: UICollectionView) -> Int
5252
func collectionView(_ collectionView: UICollectionView, dequeueForItemAt dequeueIndexPath: IndexPath, cellForItemAt usableIndexPath: IndexPath) -> UICollectionViewCell
5353

5454
// optional
55-
func collectionView(_ collectionView: UICollectionView, didSelectItemAt usableIndexPath: IndexPath)
55+
func infiniteCollectionView(_ collectionView: UICollectionView, didSelectItemAt usableIndexPath: IndexPath)
5656
func scrollView(_ scrollView: UIScrollView, pageIndex: Int)
5757
```
5858

0 commit comments

Comments
 (0)