CellRegistration 1.4.0

CellRegistration 1.4.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2017年10月
SwiftSwift 版本4.0
SPM支持 SPM

Grzegorz Krukowski 维护。



  • Grzegorz Krukowski

CellRegistration

一劳永逸的一条命令

用于注册、从队列中获取、 casting cells 的简短的替换方案,适用于 UITableView 和 UICollectionView

而不是

tableView.register(MyCustomCell.self, forCellReuseIdentifier: "MyCustomCell")
let cell : MyCustomCell = tableView.dequeueReusableCell(withIdentifier: "MyCustomCell", for: indexPath) as! MyCustomCell

现在只需这样做

let : MyCustomCell = tableView.dequeueReusableCell(forIndexPath: indexPath)

无需代码重构,您可以将其与使用旧方式的项目一起使用。无需担心任何注册、重复使用标识符、casting。

从 nib 文件加载的 cells

不考虑单元格类型(从代码中加载或从 nib 文件中加载),代码总是相同的

唯一的要求是创建一个与类名同名的 xib 文件。

let : MyCustomCell = tableView.dequeueReusableCell(forIndexPath: indexPath)
let : MyCustomCellLoadedFromXib = tableView.dequeueReusableCell(forIndexPath: indexPath)

或者

tableView.dequeueReusableCell(forIndexPath: indexPath) as MyCustomCell
tableView.dequeueReusableCell(forIndexPath: indexPath) as MyCustomCellLoadedFromXib

此 pod 将搜索与类名匹配的 xib 文件并自动注册该 nib,否则它将按类名注册单元格。

示例

要运行示例项目,首先从仓库中克隆它,然后在 Example 目录中运行 pod install

安装

CellRegistration 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "CellRegistration"

作者

Grzegorz Krukowski, [email protected]

许可证

CellRegistration 可在 MIT 许可下获得。有关更多信息,请参阅 LICENSE 文件。