cdts/xdts-ios 3/TreeHole/CYHResetCode/CYH/QMUIKit/QMUIComponents/QMUICellHeightKeyCache/UITableView+QMUICellHeightKeyCache.h

50 lines
3.4 KiB
C
Raw Normal View History

2023-07-27 09:20:00 +08:00
/**
* Tencent is pleased to support the open source community by making QMUI_iOS available.
* Copyright (C) 2016-2021 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
//
// UITableView+QMUICellHeightKeyCache.h
// QMUIKit
//
// Created by QMUI Team on 2018/3/14.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class QMUICellHeightKeyCache;
/**
* self-sizing cell 使
* 1. tableView.qmui_cacheCellHeightByKeyAutomatically = YES
* 2. tableView delegate qmui_tableView:cacheKeyForRowAtIndexPath: key key
*
* @note 使 self-sizing tableView tableView.rowHeight = UITableViewAutomaticDimensionQMUICellHeightKeyCache willDisplayCell cell heightForRow 使
* @note tableView qmui_cacheCellHeightByKeyAutomatically tableView.delegate tableView:heightForRowAtIndexPath: >= 0使 < 0 QMUICellHeightKeyCache
* @note tableView qmui_cacheCellHeightByKeyAutomatically tableView.delegate tableView:estimatedHeightForRowAtIndexPath: indexPath cell tableView:estimatedHeightForRowAtIndexPath: indexPath key
*
* @note UITableView contentInsetsafeAreaInsets iPad
*/
@interface UITableView (QMUICellHeightKeyCache)
/// 控制是否要自动缓存 cell 的高度,默认为 NO
@property(nonatomic, assign) BOOL qmui_cacheCellHeightByKeyAutomatically;
/// 获取当前的缓存容器。tableView 的宽度和 contentInset 发生变化时,这个数组也会跟着变,但当 tableView 宽度小于 0 时会返回 nil。
@property(nonatomic, weak, readonly, nullable) QMUICellHeightKeyCache *qmui_currentCellHeightKeyCache;
/// 搭配 QMUICellHeightKeyCache清除某个指定 key 的缓存,注意不要直接调用 self.qmui_currentCellHeightKeyCache.invalidateHeightForKey因为一个 UITableView 里会包含多个 QMUICellHeightKeyCache那样写只能刷新当前的 QMUICellHeightKeyCache其他宽度下的 QMUICellHeightKeyCache 无法刷新。
- (void)qmui_invalidateCellHeightCachedForKey:(id<NSCopying>)key;
/// 搭配 QMUICellHeightKeyCache清除所有状态下的缓存
- (void)qmui_invalidateAllCellHeightKeyCache;
@end
NS_ASSUME_NONNULL_END