fix scroll delegate

This commit is contained in:
Max Sokolov 2016-05-28 14:34:37 +03:00
parent 82fce34c2e
commit 7f1edda39e
3 changed files with 33 additions and 2 deletions

View File

@ -26,12 +26,13 @@ import UIKit
public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
public private(set) weak var tableView: UITableView?
public weak var scrollDelegate: UIScrollViewDelegate?
private weak var scrollDelegate: UIScrollViewDelegate?
private var sections = [TableSectionBuilder]()
public init(tableView: UITableView) {
public init(tableView: UITableView, scrollDelegate: UIScrollViewDelegate? = nil) {
super.init()
self.scrollDelegate = scrollDelegate
self.tableView = tableView
self.tableView?.delegate = self
self.tableView?.dataSource = self

View File

@ -43,5 +43,17 @@ public class TableRowBuilder<DataType, CellType: ConfigurableCell where CellType
public override func estimatedRowHeight(index: Int) -> CGFloat {
return CGFloat(CellType.estimatedHeight())
}
}
public class LolRowBuilder {
public init() {
}
public func append<ItemType, CellType: ConfigurableCell where CellType.T == ItemType, CellType: UITableViewCell>(items: [ItemType], cellType: CellType.Type) {
}
}

View File

@ -9,6 +9,19 @@
import UIKit
import Tablet
class LolCell: UITableViewCell, ConfigurableCell {
typealias T = String
func configure(str: T) {
}
static func estimatedHeight() -> Float {
return 44
}
}
class MainController: UIViewController {
@IBOutlet weak var tableView: UITableView! {
@ -28,9 +41,14 @@ class MainController: UIViewController {
let rows2 = TablePrototypeRowBuilder<String, StoryboardImageTableViewCell>(items: ["1", "1", "1", "1"])
// animation task
rows.remove(index: 0, animated: .None)
tableDirector += rows
tableDirector += rows2
let lolBuilder = LolRowBuilder()
lolBuilder.append(["1", "2", "3"], cellType: LolCell.self)
}
}