TableViewKit 1.2.0

TableViewKit 1.2.0

测试测试通过
Lang语言 SwiftSwift
许可证 MIT
发布最新版本2017 年 10 月
SPM支持 SPM

Alfredo Delli BoviNelson 维护。



  • TableViewKit 贡献者

TableViewKit


赋予 UITableView 无痛的多类型单元支持及内置自动状态过渡动画

入门

概览

TableViewKit 是为了简化开发而设计的

  • 不同头部、尾部以及多种单元类型的自定义分区
  • 支持状态性的分区
  • 确保可重复使用和可测试性
  • 最后但同样重要的是,您可以忘记 UITableView 的代理

快速入门

创建一个包含 UITableViewCellCellDrawerItem。一个 Item 可能有显示所需数据的模型,并可控制任何交互。

class YourDrawer: CellDrawer {

    // The type could be a custom UITableViewCell class, with or without a Nib
    static var type = CellType.class(YourCustomCell.self)

    static func draw(_ cell: YourCustomCell, with item: YourItem) {
        // Draw by setting properties of your cell from the item
    }
}

class YourItem: Item {

    var drawer = AnyCellDrawer(YourDrawer.self)

    // Your properties and methods

    public init() { }
}

使用您的项目创建自定义 Section

class YourSection: Section {
    var items: ObservableArray<Item>

    var header: HeaderFooterView = .title("Your section")

    public init() {
      items = [YourItem(), AnotherItem(), AndAnotherItem()]
    }
}

一切准备就绪,实例化一个 TableViewManager,并在您的带有 UITableViewUIViewController 中传递自定义分区数组。

class ViewController: UIViewController {
    var tableViewManager: TableViewManager!

    @IBOutlet weak var tableView: UITableView! {
        didSet {
            tableViewManager = TableViewManager(tableView: tableView, sections: [CustomSection])
        }
    }
}

示例

要求

  • Xcode 8 或更高版本
  • iOS 8.0 或更高版本

安装

手动安装

  1. 下载并将 /TableViewKit 文件夹拖到您的项目中。
  2. 恭喜您!

交流

  • 如果您 发现了一个错误,请提交问题。
  • 如果您 有功能请求,请提交问题。
  • 如果您 想贡献,提交 pull request。