Skip to content

Commit

Permalink
Add indexForCell:
Browse files Browse the repository at this point in the history
  • Loading branch information
WenchaoD committed Mar 15, 2017
1 parent de1bfbb commit f84475a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/FSPagerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,18 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
self.collectionView.setContentOffset(contentOffset, animated: animated)
}

/// Returns the index of the specified cell.
///
/// - Parameter cell: The cell object whose index you want.
/// - Returns: The index of the cell or NSNotFound if the specified cell is not in the pager view.
@objc(indexForCell:)
open func index(for cell: FSPagerViewCell) -> Int {
guard let indexPath = self.collectionView.indexPath(for: cell) else {
return NSNotFound
}
return indexPath.item
}

// MARK: - Private functions

fileprivate func commonInit() {
Expand Down

0 comments on commit f84475a

Please sign in to comment.