UITableView

extension UITableView: SkeletonViewDataSource

UITableView骨架屏视图数据源扩展

StatisticalViewProtocol

TableViewDelegate

Cache

  • 手工清空高度缓存,用于高度发生变化的情况

    Declaration

    Swift

    public func fw_clearHeightCache()
  • 指定key设置cell高度缓存,如willDisplayCell调用,height为cell.frame.size.height,设置为0时清除缓存

    Declaration

    Swift

    public func fw_setCellHeightCache(_ height: CGFloat, for key: AnyHashable)
  • 指定key获取cell缓存高度,如estimatedHeightForRow调用,默认值automaticDimension

    Declaration

    Swift

    public func fw_cellHeightCache(for key: AnyHashable) -> CGFloat
  • 指定key设置HeaderFooter高度缓存,如willDisplayHeaderFooter调用,height为view.frame.size.height,设置为0时清除缓存

    Declaration

    Swift

    public func fw_setHeaderFooterHeightCache(_ height: CGFloat, type: HeaderFooterViewType, for key: AnyHashable)
  • 指定key获取HeaderFooter缓存高度,如estimatedHeightForHeaderFooter调用,默认值automaticDimension

    Declaration

    Swift

    public func fw_headerFooterHeightCache(_ type: HeaderFooterViewType, for key: AnyHashable) -> CGFloat

Cell

  • 获取 Cell 需要的高度,可指定key使用缓存

    Declaration

    Swift

    public func fw_height(
        cellClass: UITableViewCell.Type,
        cacheBy key: AnyHashable? = nil,
        configuration: (UITableViewCell) -> Void
    ) -> CGFloat

    Parameters

    cellClass

    cell class

    key

    使用 key 做缓存标识,如数据唯一id,对象hash等,默认nil

    configuration

    布局 cell,内部不会拥有 Block,不需要 __weak

    Return Value

    cell高度

HeaderFooterView

  • 获取 HeaderFooter 需要的高度,可指定key使用缓存

    Declaration

    Swift

    public func fw_height(
        headerFooterViewClass: UITableViewHeaderFooterView.Type,
        type: HeaderFooterViewType,
        cacheBy key: AnyHashable? = nil,
        configuration: (UITableViewHeaderFooterView) -> Void
    ) -> CGFloat

    Parameters

    headerFooterViewClass

    HeaderFooter class

    type

    HeaderFooter类型,Header 或者 Footer

    key

    使用 key 做缓存标识,如数据唯一id,对象hash等,默认nil

    configuration

    布局 HeaderFooter,内部不会拥有 Block,不需要 __weak

    Return Value

    HeaderFooter高度

UITableView+UIKit

  • 全局清空TableView默认多余边距

    Declaration

    Swift

    public static func fw_resetTableStyle()
  • 是否启动高度估算布局,启用后需要子视图布局完整,无需实现heightForRow方法(iOS11默认启用,会先cellForRow再heightForRow)

    Declaration

    Swift

    public var fw_estimatedLayout: Bool { get set }
  • 清除Grouped等样式默认多余边距,注意CGFLOAT_MIN才会生效,0不会生效

    Declaration

    Swift

    public func fw_resetTableStyle()
  • 配置全局resetTableStyle钩子句柄,默认nil

    Declaration

    Swift

    public static var fw_resetTableConfiguration: ((UITableView) -> Void)?
  • reloadData完成回调

    Declaration

    Swift

    public func fw_reloadData(completion: (() -> Void)?)
  • reloadData禁用动画

    Declaration

    Swift

    public func fw_reloadDataWithoutAnimation()
  • 判断indexPath是否有效

    Declaration

    Swift

    public func fw_isValidIndexPath(_ indexPath: IndexPath) -> Bool
  • 简单曝光方案,willDisplay调用即可,表格快速滑动、数据不变等情况不计曝光。如需完整曝光方案,请使用StatisticalView

    Declaration

    Swift

    public func fw_willDisplay(_ cell: UITableViewCell, at indexPath: IndexPath, key: AnyHashable? = nil, exposure: @escaping () -> Void)