UICollectionView(FWDynamicLayout)
@interface UICollectionView (FWDynamicLayout)
集合自动计算并缓存cell高度分类,最底部view的MaxY即为cell高度,自定义方案实现
如果使用系统自动尺寸,建议设置estimatedItemSize提高性能
-
手工清空尺寸缓存,用于尺寸发生变化的情况
Declaration
Objective-C
- (void)fw_clearSizeCache;
-
指定indexPath设置cell尺寸缓存,设置为zero时清除缓存
Declaration
Objective-C
- (void)fw_setCellSizeCache:(CGSize)size forIndexPath:(nonnull NSIndexPath *)indexPath;
-
指定key设置cell尺寸缓存,设置为zero时清除缓存
Declaration
Objective-C
- (void)fw_setCellSizeCache:(CGSize)size forKey:(nonnull id<NSCopying>)key;
-
指定indexPath获取cell缓存尺寸,默认值automaticSize
Declaration
Objective-C
- (CGSize)fw_cellSizeCacheForIndexPath:(nonnull NSIndexPath *)indexPath;
-
指定key获取cell缓存尺寸,默认值automaticSize
Declaration
Objective-C
- (CGSize)fw_cellSizeCacheForKey:(nonnull id<NSCopying>)key;
-
指定section设置ReusableView尺寸缓存,设置为zero时清除缓存
Declaration
Objective-C
- (void)fw_setReusableViewSizeCache:(CGSize)size kind:(nonnull NSString *)kind forSection:(NSInteger)section;
-
指定key设置ReusableView尺寸缓存,设置为zero时清除缓存
Declaration
Objective-C
- (void)fw_setReusableViewSizeCache:(CGSize)size kind:(nonnull NSString *)kind forKey:(nonnull id<NSCopying>)key;
-
指定section获取ReusableView缓存尺寸,默认值automaticSize
Declaration
Objective-C
- (CGSize)fw_reusableViewSizeCache:(nonnull NSString *)kind forSection:(NSInteger)section;
-
指定key获取ReusableView缓存尺寸,默认值automaticSize
Declaration
Objective-C
- (CGSize)fw_reusableViewSizeCache:(nonnull NSString *)kind forKey:(nonnull id<NSCopying>)key;
-
获取 Cell 需要的尺寸,内部无缓存操作
Declaration
Objective-C
- (CGSize)fw_sizeWithCellClass:(nonnull Class)clazz configuration: (nonnull FWCollectionCellConfigurationBlock)configuration;
Parameters
clazz
cell类
configuration
布局cell句柄,内部不会拥有Block,不需要__weak
Return Value
cell尺寸
-
获取 Cell 需要的尺寸,固定宽度,内部无缓存操作
Declaration
Objective-C
- (CGSize)fw_sizeWithCellClass:(nonnull Class)clazz width:(CGFloat)width configuration: (nonnull FWCollectionCellConfigurationBlock)configuration;
Parameters
clazz
cell类
width
固定宽度
configuration
布局cell句柄,内部不会拥有Block,不需要__weak
Return Value
cell尺寸
-
获取 Cell 需要的尺寸,固定高度,内部无缓存操作
Declaration
Objective-C
- (CGSize)fw_sizeWithCellClass:(nonnull Class)clazz height:(CGFloat)height configuration: (nonnull FWCollectionCellConfigurationBlock)configuration;
Parameters
clazz
cell类
height
固定高度
configuration
布局cell句柄,内部不会拥有Block,不需要__weak
Return Value
cell尺寸
-
获取 Cell 需要的尺寸,内部自动处理缓存,缓存标识 indexPath
Declaration
Objective-C
- (CGSize)fw_sizeWithCellClass:(nonnull Class)clazz cacheByIndexPath:(nonnull NSIndexPath *)indexPath configuration: (nonnull FWCollectionCellConfigurationBlock)configuration;
Parameters
clazz
cell class
indexPath
使用 indexPath 做缓存标识
configuration
布局 cell,内部不会拥有 Block,不需要 __weak
-
获取 Cell 需要的尺寸,固定宽度,内部自动处理缓存,缓存标识 indexPath
Declaration
Objective-C
- (CGSize)fw_sizeWithCellClass:(nonnull Class)clazz width:(CGFloat)width cacheByIndexPath:(nonnull NSIndexPath *)indexPath configuration: (nonnull FWCollectionCellConfigurationBlock)configuration;
Parameters
clazz
cell class
width
固定宽度
indexPath
使用 indexPath 做缓存标识
configuration
布局 cell,内部不会拥有 Block,不需要 __weak
-
获取 Cell 需要的尺寸,固定高度,内部自动处理缓存,缓存标识 indexPath
Declaration
Objective-C
- (CGSize)fw_sizeWithCellClass:(nonnull Class)clazz height:(CGFloat)height cacheByIndexPath:(nonnull NSIndexPath *)indexPath configuration: (nonnull FWCollectionCellConfigurationBlock)configuration;
Parameters
clazz
cell class
height
固定高度
indexPath
使用 indexPath 做缓存标识
configuration
布局 cell,内部不会拥有 Block,不需要 __weak
-
获取 Cell 需要的尺寸,内部自动处理缓存,缓存标识 key
Declaration
Objective-C
- (CGSize)fw_sizeWithCellClass:(nonnull Class)clazz cacheByKey:(nullable id<NSCopying>)key configuration: (nonnull FWCollectionCellConfigurationBlock)configuration;
Parameters
clazz
cell class
key
使用 key 做缓存标识,如数据唯一id,对象hash等
configuration
布局 cell,内部不会拥有 Block,不需要 __weak
-
获取 Cell 需要的尺寸,固定宽度,内部自动处理缓存,缓存标识 key
Declaration
Objective-C
- (CGSize)fw_sizeWithCellClass:(nonnull Class)clazz width:(CGFloat)width cacheByKey:(nullable id<NSCopying>)key configuration: (nonnull FWCollectionCellConfigurationBlock)configuration;
Parameters
clazz
cell class
width
固定宽度
key
使用 key 做缓存标识,如数据唯一id,对象hash等
configuration
布局 cell,内部不会拥有 Block,不需要 __weak
-
获取 Cell 需要的尺寸,固定高度,内部自动处理缓存,缓存标识 key
Declaration
Objective-C
- (CGSize)fw_sizeWithCellClass:(nonnull Class)clazz height:(CGFloat)height cacheByKey:(nullable id<NSCopying>)key configuration: (nonnull FWCollectionCellConfigurationBlock)configuration;
Parameters
clazz
cell class
height
固定高度
key
使用 key 做缓存标识,如数据唯一id,对象hash等
configuration
布局 cell,内部不会拥有 Block,不需要 __weak
-
获取 ReusableView 需要的尺寸,内部无缓存操作
Declaration
Objective-C
- (CGSize)fw_sizeWithReusableViewClass:(nonnull Class)clazz kind:(nonnull NSString *)kind configuration: (nonnull FWReusableViewConfigurationBlock) configuration;
Parameters
clazz
ReusableView class
kind
ReusableView类型,Header 或者 Footer
configuration
布局 ReusableView,内部不会拥有 Block,不需要 __weak
-
获取 ReusableView 需要的尺寸,固定宽度,内部无缓存操作
Declaration
Objective-C
- (CGSize)fw_sizeWithReusableViewClass:(nonnull Class)clazz width:(CGFloat)width kind:(nonnull NSString *)kind configuration: (nonnull FWReusableViewConfigurationBlock) configuration;
Parameters
clazz
ReusableView class
width
固定宽度
kind
ReusableView类型,Header 或者 Footer
configuration
布局 ReusableView,内部不会拥有 Block,不需要 __weak
-
获取 ReusableView 需要的尺寸,固定高度,内部无缓存操作
Declaration
Objective-C
- (CGSize)fw_sizeWithReusableViewClass:(nonnull Class)clazz height:(CGFloat)height kind:(nonnull NSString *)kind configuration: (nonnull FWReusableViewConfigurationBlock) configuration;
Parameters
clazz
ReusableView class
height
固定高度
kind
ReusableView类型,Header 或者 Footer
configuration
布局 ReusableView,内部不会拥有 Block,不需要 __weak
-
获取 ReusableView 需要的尺寸,内部自动处理缓存,缓存标识 section
Declaration
Objective-C
- (CGSize)fw_sizeWithReusableViewClass:(nonnull Class)clazz kind:(nonnull NSString *)kind cacheBySection:(NSInteger)section configuration: (nonnull FWReusableViewConfigurationBlock) configuration;
Parameters
clazz
ReusableView class
kind
ReusableView类型,Header 或者 Footer
section
使用 section 做缓存标识
configuration
布局 ReusableView,内部不会拥有 Block,不需要 __weak
-
获取 ReusableView 需要的尺寸,固定宽度,内部自动处理缓存,缓存标识 section
Declaration
Objective-C
- (CGSize)fw_sizeWithReusableViewClass:(nonnull Class)clazz width:(CGFloat)width kind:(nonnull NSString *)kind cacheBySection:(NSInteger)section configuration: (nonnull FWReusableViewConfigurationBlock) configuration;
Parameters
clazz
ReusableView class
width
固定宽度
kind
ReusableView类型,Header 或者 Footer
section
使用 section 做缓存标识
configuration
布局 ReusableView,内部不会拥有 Block,不需要 __weak
-
获取 ReusableView 需要的尺寸,固定高度,内部自动处理缓存,缓存标识 section
Declaration
Objective-C
- (CGSize)fw_sizeWithReusableViewClass:(nonnull Class)clazz height:(CGFloat)height kind:(nonnull NSString *)kind cacheBySection:(NSInteger)section configuration: (nonnull FWReusableViewConfigurationBlock) configuration;
Parameters
clazz
ReusableView class
height
固定高度
kind
ReusableView类型,Header 或者 Footer
section
使用 section 做缓存标识
configuration
布局 ReusableView,内部不会拥有 Block,不需要 __weak
-
获取 ReusableView 需要的尺寸,内部自动处理缓存,缓存标识 key
Declaration
Objective-C
- (CGSize)fw_sizeWithReusableViewClass:(nonnull Class)clazz kind:(nonnull NSString *)kind cacheByKey:(nullable id<NSCopying>)key configuration: (nonnull FWReusableViewConfigurationBlock) configuration;
Parameters
clazz
ReusableView class
kind
ReusableView类型,Header 或者 Footer
key
使用 key 做缓存标识,如数据唯一id,对象hash等
configuration
布局 ReusableView,内部不会拥有 Block,不需要 __weak
-
获取 ReusableView 需要的尺寸,固定宽度,内部自动处理缓存,缓存标识 key
Declaration
Objective-C
- (CGSize)fw_sizeWithReusableViewClass:(nonnull Class)clazz width:(CGFloat)width kind:(nonnull NSString *)kind cacheByKey:(nullable id<NSCopying>)key configuration: (nonnull FWReusableViewConfigurationBlock) configuration;
Parameters
clazz
ReusableView class
width
固定宽度
kind
ReusableView类型,Header 或者 Footer
key
使用 key 做缓存标识,如数据唯一id,对象hash等
configuration
布局 ReusableView,内部不会拥有 Block,不需要 __weak
-
获取 ReusableView 需要的尺寸,固定高度,内部自动处理缓存,缓存标识 key
Declaration
Objective-C
- (CGSize)fw_sizeWithReusableViewClass:(nonnull Class)clazz height:(CGFloat)height kind:(nonnull NSString *)kind cacheByKey:(nullable id<NSCopying>)key configuration: (nonnull FWReusableViewConfigurationBlock) configuration;
Parameters
clazz
ReusableView class
height
固定高度
kind
ReusableView类型,Header 或者 Footer
key
使用 key 做缓存标识,如数据唯一id,对象hash等
configuration
布局 ReusableView,内部不会拥有 Block,不需要 __weak
-
reloadData完成回调
Declaration
Objective-C
- (void)fw_reloadDataWithCompletion:(nullable void (^)(void))completion;
-
reloadData禁用动画
Declaration
Objective-C
- (void)fw_reloadDataWithoutAnimation;