UICollectionView
public extension UICollectionView
-
SwifterSwift: Index path of last item in collectionView.
Declaration
Swift
var indexPathForLastItem: IndexPath? { get }
-
SwifterSwift: Index of last section in collectionView.
Declaration
Swift
var lastSection: Int { get }
-
SwifterSwift: Number of all items in all sections of collectionView.
Declaration
Swift
func numberOfItems() -> Int
Return Value
The count of all rows in the collectionView.
-
SwifterSwift: IndexPath for last item in section.
Declaration
Swift
func indexPathForLastItem(inSection section: Int) -> IndexPath?
Parameters
section
section to get last item in.
Return Value
optional last indexPath for last item in section (if applicable).
-
SwifterSwift: Reload data with a completion handler.
Declaration
Swift
func reloadData(_ completion: @escaping () -> Void)
Parameters
completion
completion handler to run after reloadData finishes.
-
SwifterSwift: Dequeue reusable UICollectionViewCell using class name.
Declaration
Swift
func dequeueReusableCell<T>(withClass name: T.Type, for indexPath: IndexPath) -> T where T : UICollectionViewCell
Parameters
name
UICollectionViewCell type.
indexPath
location of cell in collectionView.
Return Value
UICollectionViewCell object with associated class name.
-
SwifterSwift: Dequeue reusable UICollectionReusableView using class name.
Declaration
Swift
func dequeueReusableSupplementaryView<T>(ofKind kind: String, withClass name: T.Type, for indexPath: IndexPath) -> T where T : UICollectionReusableView
Parameters
kind
the kind of supplementary view to retrieve. This value is defined by the layout object.
name
UICollectionReusableView type.
indexPath
location of cell in collectionView.
Return Value
UICollectionReusableView object with associated class name.
-
SwifterSwift: Register UICollectionReusableView using class name.
Declaration
Swift
func register<T>(supplementaryViewOfKind kind: String, withClass name: T.Type) where T : UICollectionReusableView
Parameters
kind
the kind of supplementary view to retrieve. This value is defined by the layout object.
name
UICollectionReusableView type.
-
SwifterSwift: Register UICollectionViewCell using class name.
Declaration
Swift
func register<T>(nib: UINib?, forCellWithClass name: T.Type) where T : UICollectionViewCell
Parameters
nib
Nib file used to create the collectionView cell.
name
UICollectionViewCell type.
-
SwifterSwift: Register UICollectionViewCell using class name.
Declaration
Swift
func register<T>(cellWithClass name: T.Type) where T : UICollectionViewCell
Parameters
name
UICollectionViewCell type.
-
SwifterSwift: Register UICollectionReusableView using class name.
Declaration
Swift
func register<T>(nib: UINib?, forSupplementaryViewOfKind kind: String, withClass name: T.Type) where T : UICollectionReusableView
Parameters
nib
Nib file used to create the reusable view.
kind
the kind of supplementary view to retrieve. This value is defined by the layout object.
name
UICollectionReusableView type.
-
SwifterSwift: Register UICollectionViewCell with .xib file using only its corresponding class. Assumes that the .xib filename and cell class has the same name.
Declaration
Swift
func register<T>(nibWithCellClass name: T.Type, at bundleClass: AnyClass? = nil) where T : UICollectionViewCell
Parameters
name
UICollectionViewCell type.
bundleClass
Class in which the Bundle instance will be based on.
-
SwifterSwift: Safely scroll to possibly invalid IndexPath
Declaration
Swift
func safeScrollToItem(at indexPath: IndexPath, at scrollPosition: UICollectionView.ScrollPosition, animated: Bool)
Parameters
indexPath
Target IndexPath to scroll to
scrollPosition
Scroll position
animated
Whether to animate or not
-
SwifterSwift: Check whether IndexPath is valid within the CollectionView
Declaration
Swift
func isValidIndexPath(_ indexPath: IndexPath) -> Bool
Parameters
indexPath
An IndexPath to check
Return Value
Boolean value for valid or invalid IndexPath