LCXReuseViewID 0.1.2

LCXReuseViewID 0.1.2

lcx 维护。



LCXReuseViewID

CI Status Version License Platform

作用:注册复用 view 的超级简便使用;

支持:UITableViewCellStyle、UITableViewHeaderFooterView、UICollectionViewCellStyle、UICollectionReusableView;

思路:

1 以复用 View 的类名作为复用 id;2 通过 runtime 给分类添加属性;

优点:

以 UITableViewCell 子类的注册复用为例:1 免 import 使用 cell 的头文件;2 免命名 reuseID;3 免重复 register 复用 cell 类(特别是 cell 种类多时,代码简化作用明显);4 防止 reuseID 在 register 时和在 table view delegate 使用时,不一致错误;5 打印提示:未注册成功的类名字符串;

注册复用cell代码

_tableView.lcx_registerCellClassNames = @[@"ATableViewCell",@"BTableViewCell"]; _tableView.lcx_registerHeaderFooterClassNames = @[@"AHeaderFooterView",@"BHeaderFooterView"];

示例

要运行示例项目,请先克隆存储库,然后从示例目录运行 pod install

需求

安装

LCXReuseViewID 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中

pod 'LCXReuseViewID'

作者

[email protected], [email protected]

许可证

LCXReuseViewID 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。