QMUICellHeightKeyCache
@interface QMUICellHeightKeyCache : NSObject
通过业务定义的一个 key 来缓存 cell 的高度,需搭配 UITableView 使用,一般不用你自己去 init。 具体使用方式请看 UITableView (QMUICellHeightKeyCache) 的注释。
-
检查是否存在某个 key 的高度
Declaration
Objective-C
- (BOOL)existsHeightForKey:(nonnull id<NSCopying>)key;
Swift
func existsHeight(forKey key: NSCopying) -> Bool
-
将某个高度缓存到指定的 key
Declaration
Objective-C
- (void)cacheHeight:(CGFloat)height forKey:(nonnull id<NSCopying>)key;
Swift
func cacheHeight(_ height: CGFloat, forKey key: NSCopying)
-
获取指定 key 对应的高度,如果该 key 不存在,则返回 0
Declaration
Objective-C
- (CGFloat)heightForKey:(nonnull id<NSCopying>)key;
Swift
func height(forKey key: NSCopying) -> CGFloat
-
令指定 key 的缓存失效。注意如果在业务里,应该调用 [UITableView -qmui_invalidateCellHeightCachedForKey:],而不应该直接调用这个方法。
Declaration
Objective-C
- (void)invalidateHeightForKey:(nonnull id<NSCopying>)key;
Swift
func invalidateHeight(forKey key: NSCopying)
-
令所有的缓存失效。注意如果在业务里,应该调用 [UITableView -qmui_invalidateAllCellHeightKeyCache],而不应该直接调用这个方法。
Declaration
Objective-C
- (void)invalidateAllHeightCache;
Swift
func invalidateAllHeightCache()