TableViewTools 0.0.8

TableViewTools 0.0.8

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2018年2月
SwiftSwift 版本3.0
SPM支持 SPM

Dmitry FrishbuterNikita Ermolenko 维护。



  • 作者:
  • Dmitry Frishbuter

TableViewTools

概述

此仓库包含制作您的 UITableView 使用简单且舒适的有力工具!它允许您将您的 UITableView 配置逻辑移至分离的对象,例如继承自 TableViewSectionItemProtocol 和 TableViewCellItemProtocol 的对象,并简单地注册、添加和从您的表格视图中删除单元格。

示例

要运行示例项目,请运行 pod try,或者简单克隆仓库并打开项目 Example-iOS。

要求


基本用法

创建管理器

    manager = TableViewManager(tableView: tableView)

创建分区

    let titles = ["Item 1", "Item 2", "Item 3"]
    var cellItems = [ExampleTableViewCellItem]()
    titles.forEach { title in
        let cellItem = ExampleTableViewCellItem(title: title)
        cellItems.append(cellItem)
    }

    let sectionItem = TableViewSectionItem(cellItems: cellItems)
    manager.sectionItems = [sectionItem]

单元格项实现

对于基本用法,在单元格项中应实现这些来自 TableViewCellItemProtocol 的条目:

    class ExampleTableViewCellItem: TableViewCellItemProtocol {

        var reuseType: ReuseType {
            return ReuseType(cellClass: ExampleTableViewCell.self)
        }

        func height(in tableView: UITableView) -> CGFloat {
            return 100
        }

        func cellForTableView(tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
            let cell: ExampleTableViewCell = tableView.dequeueReusableCell()
            return cell
        }
    }

作者

许可证

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