fix scroll delegate
This commit is contained in:
parent
82fce34c2e
commit
7f1edda39e
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue