UICollectionView(QMUI)
@interface UICollectionView (QMUI)
/**
* 清除所有已选中的item的选中状态
*/
- (void)qmui_clearsSelection;
/**
* 重新`reloadData`,同时保持`reloadData`前item的选中状态
*/
- (void)qmui_reloadDataKeepingSelection;
/**
* 获取某个view在collectionView内对应的indexPath
*
* 例如某个view是某个cell里的subview,在这个view的点击事件回调方法里,就能通过`qmui_indexPathForItemAtView:`获取被点击的view所处的cell的indexPath
*
* @warning 注意返回的indexPath有可能为nil,要做保护。
*/
- (NSIndexPath *)qmui_indexPathForItemAtView:(id)sender;
/**
* 判断当前 indexPath 的 item 是否为可视的 item
*/
- (BOOL)qmui_itemVisibleAtIndexPath:(NSIndexPath *)indexPath;
/**
* 对系统的 indexPathsForVisibleItems 进行了排序后的结果
*/
- (NSArray<NSIndexPath *> *)qmui_indexPathsForVisibleItems;
/**
* 获取可视区域内第一个cell的indexPath。
*
* 为什么需要这个方法是因为系统的indexPathsForVisibleItems方法返回的数组成员是无序排列的,所以不能直接通过firstObject拿到第一个cell。
*
* @warning 若可视区域为CGRectZero,则返回nil
*/
- (NSIndexPath *)qmui_indexPathForFirstVisibleCell;
@end
Undocumented
-
清除所有已选中的item的选中状态
Declaration
Objective-C
- (void)qmui_clearsSelection;
Swift
func qmui_clearsSelection()
-
重新
reloadData
,同时保持reloadData
前item的选中状态Declaration
Objective-C
- (void)qmui_reloadDataKeepingSelection;
Swift
func qmui_reloadDataKeepingSelection()
-
获取某个view在collectionView内对应的indexPath
例如某个view是某个cell里的subview,在这个view的点击事件回调方法里,就能通过
qmui_indexPathForItemAtView:
获取被点击的view所处的cell的indexPathWarning
注意返回的indexPath有可能为nil,要做保护。Declaration
Objective-C
- (NSIndexPath *)qmui_indexPathForItemAtView:(id)sender;
Swift
func qmui_indexPathForItemAtView(_ sender: Any!) -> IndexPath!
-
判断当前 indexPath 的 item 是否为可视的 item
Declaration
Objective-C
- (BOOL)qmui_itemVisibleAtIndexPath:(NSIndexPath *)indexPath;
Swift
func qmui_itemVisible(at indexPath: IndexPath!) -> Bool
-
对系统的 indexPathsForVisibleItems 进行了排序后的结果
Declaration
Objective-C
- (NSArray<NSIndexPath *> *)qmui_indexPathsForVisibleItems;
Swift
func qmui_indexPathsForVisibleItems() -> [IndexPath]!
-
获取可视区域内第一个cell的indexPath。
为什么需要这个方法是因为系统的indexPathsForVisibleItems方法返回的数组成员是无序排列的,所以不能直接通过firstObject拿到第一个cell。
Warning
若可视区域为CGRectZero,则返回nilDeclaration
Objective-C
- (NSIndexPath *)qmui_indexPathForFirstVisibleCell;
Swift
func qmui_indexPathForFirstVisibleCell() -> IndexPath!