UICollectionView related methods,
I have nothing to worry about recently. Sort out the related methods of UICollectionView for use.
UICollectionViewFlowLayout and UICollectionViewLayout
UICollectionViewFlowLayout is a subclass of UICollectionViewLayout. We usually use UICollectionViewFlowLayout. UICollectionViewLayout is an abstract base class, which is defined as a common excuse and cannot be used directly. When using this class, you should first check whether its subclass UICollectionViewFlowLayout meets the requirements. Otherwise, you can customize the subclass.
UICollectionViewFlowLayout attributes that are frequently used:
MinimumLineSpacing: Minimum Line spacing
MinimumInteritemSpacing: Minimum item spacing
ItemSize: item size
EstimatedItemSize: predefined item size
ScrollDirection: Scroll direction
HeaderReferenceSize: sectionHeader size
FooterReferenceSize: sectionfooter size
SectionInset: padding size
SectionHeadersPinToVisibleBounds: SectionHeader floating
SectionFootersPinToVisibleBounds: SectionFooter floating
UICollectionViewDelegate
-(BOOL) collectionView :( UICollectionView *) collectionView shouldHighlightItemAtIndexPath :( NSIndexPath *) indexPath; // YES, the highlighted state is displayed when you click cell.
-(Void) collectionView :( UICollectionView *) collectionView didHighlightItemAtIndexPath :( NSIndexPath *) indexPath; // The highlighted State (the previous method must be YES)
-(Void) collectionView :( UICollectionView *) collectionView didUnhighlightItemAtIndexPath :( NSIndexPath *) indexPath; // release the finger to cancel the highlighted state.
-(BOOL) collectionView :( UICollectionView *) collectionView shouldSelectItemAtIndexPath :( NSIndexPath *) indexPath; // whether the cell can be selected
-(Void) collectionView :( UICollectionView *) collectionView didSelectItemAtIndexPath :( NSIndexPath *) indexPath; // execute the selection event when the previous method is YES
-(BOOL) collectionView :( UICollectionView *) collectionView shouldDeselectItemAtIndexPath :( NSIndexPath *) indexPath; // whether the cell can be deselected
-(Void) collectionView :( UICollectionView *) collectionView didDeselectItemAtIndexPath :( NSIndexPath *) indexPath; // triggered when the item at the specified indexPath is deselected (called only when multiple options are allowed)
-(Void) collectionView :( UICollectionView *) collectionView willDisplayCell :( UICollectionViewCell *) cell forItemAtIndexPath :( NSIndexPath *) indexPath; // call when the cell is to be displayed
-(Void) collectionView :( UICollectionView *) collectionView willDisplaySupplementaryView :( UICollectionReusableView *) view forElementKind :( NSString *) elementKind atIndexPath :( NSIndexPath *) indexPath; // call when the head or tail view of the cell is to be displayed
-(Void) collectionView :( UICollectionView *) collectionView didEndDisplayingCell :( UICollectionViewCell *) cell forItemAtIndexPath :( NSIndexPath *) indexPath; // called when the cell is to be removed from collectionView
-(Void) collectionView :( UICollectionView *) collectionView didEndDisplayingSupplementaryView :( UICollectionReusableView *) view forElementOfKind :( NSString *) elementKind atIndexPath :( NSIndexPath *) indexPath; // called when the head or tail view of the cell is to be removed from the collectionView
-(BOOL) collectionView :( UICollectionView *) collectionView shouldShowMenuForItemAtIndexPath :( NSIndexPath *) indexPath; // whether to display the editing menu when the cell is long-pressed
-(BOOL) collectionView :( UICollectionView *) collectionView canPerformAction :( SEL) action forItemAtIndexPath :( NSIndexPath *) indexPath withSender :( nullable id) sender; // For CUT and COPY) at least one of the three PASTE actions returns YES.
-(Void) collectionView :( UICollectionView *) collectionView condition maction :( SEL) action forItemAtIndexPath :( NSIndexPath *) indexPath withSender :( nullable id) sender; // when the preceding two methods meet the conditions, response operation in this method
-(UICollectionViewTransitionLayout *) collectionView :( UICollectionView *) collectionView transitionLayoutForOldLayout :( UICollectionViewLayout *) fromLayout newLayout :( UICollectionViewLayout *) toLayout; // re-Layout
-(BOOL) collectionView :( UICollectionView *) collectionView canFocusItemAtIndexPath :( NSIndexPath *) indexPath; // whether the focus can be obtained
-(BOOL) collectionView :( UICollectionView *) collectionView shouldUpdateFocusInContext :( UICollectionViewFocusUpdateContext *) context; // whether the focus can be updated
-(Void) collectionView :( UICollectionView *) collectionView didUpdateFocusInContext :( UICollectionViewFocusUpdateContext *) context withAnimationCoordinator :( optional *) coordinator; // The focus has been dynamically updated.
-(NSIndexPath *) indexPathForPreferredFocusedViewInCollectionView :( UICollectionView *) collectionView; // The preferred item
-(NSIndexPath *) collectionView :( UICollectionView *) collectionView targetIndexPathForMoveFromItemAtIndexPath :( NSIndexPath *) originalIndexPath toProposedIndexPath :( NSIndexPath *) proposedIndexPath; // restrict the movement of items
-(CGPoint) collectionView :( UICollectionView *) collectionView targetContentOffsetForProposedContentOffset :( CGPoint) proposedContentOffset; // the last position of the UICollectionView
UICollectionViewDataSource
@ Required
-(NSInteger) collectionView :( UICollectionView *) collectionView numberOfItemsInSection :( NSInteger) section; // The number of items in each group
-(UICollectionViewCell *) collectionView :( UICollectionView *) collectionView cellForItemAtIndexPath :( NSIndexPath *) indexPath; // item
@ Optional
-(NSInteger) numberOfSectionsInCollectionView :( UICollectionView *) collectionView; // number of groups
-(UICollectionReusableView *) collectionView :( UICollectionView *) collectionView viewForSupplementaryElementOfKind :( NSString *) kind atIndexPath :( NSIndexPath *) indexPath; // group header view/tail View
-(BOOL) collectionView :( UICollectionView *) collectionView canMoveItemAtIndexPath :( NSIndexPath *) indexPath; // whether the item can be moved
-(Void) collectionView :( UICollectionView *) collectionView moveItemAtIndexPath :( NSIndexPath *) sourceIndexPath toIndexPath :( NSIndexPath *) destinationIndexPath; // move item
UICollectionViewDelegateFlowLayout
-(CGSize) collectionView :( UICollectionView *) collectionView layout :( UICollectionViewLayout *) collectionViewLayout sizeForItemAtIndexPath :( NSIndexPath *) indexPath; // you can specify the item size.
-(UIEdgeInsets) collectionView :( UICollectionView *) collectionView layout :( UICollectionViewLayout *) collectionViewLayout insetForSectionAtIndex :( NSInteger) section; // the spacing between the top, bottom, and left of the item.
-(CGFloat) collectionView :( UICollectionView *) collectionView layout :( UICollectionViewLayout *) collectionViewLayout minimumLineSpacingForSectionAtIndex :( NSInteger) section; // line spacing
-(CGFloat) collectionView :( UICollectionView *) collectionView layout :( UICollectionViewLayout *) collectionViewLayout minimumInteritemSpacingForSectionAtIndex :( NSInteger) section; // item spacing
-(CGSize) collectionView :( UICollectionView *) collectionView layout :( UICollectionViewLayout *) collectionViewLayout referenceSizeForHeaderInSection :( NSInteger) section; // the size of the header View
-(CGSize) collectionView :( UICollectionView *) collectionView layout :( UICollectionViewLayout *) collectionViewLayout referenceSizeForFooterInSection :( NSInteger) section; // the size of the tail View
Uicollectionviewexcepceprefetching
@ Required
-(Void) collectionView :( UICollectionView *) collectionView prefetchItemsAtIndexPaths :( NSArray <NSIndexPath *> *) indexPaths; // pre-load indexPaths
@ Optional
-(Void) collectionView :( UICollectionView *) collectionView cancelPrefetchingForItemsAtIndexPaths :( NSArray <NSIndexPath *> *) indexPaths; // cancel pre-loading indexPaths