0
嘗試使用AsyncdisplayKit在迅速3.AsyncDisplayKit AsViewController快捷3
第一時間有一些我不明白:
我只是設置我的ASviewController:
final class NodeFeedViewController: ASViewController<ASDisplayNode>, ASTableDataSource, ASTableDelegate {
var tableNode: ASTableNode {
return node as! ASTableNode
}
init() {
super.init(node: ASTableNode())
self.node.view.backgroundColor = UIColor.purple
self.node.backgroundColor = UIColor.yellow
self.tableNode.delegate = self
self.tableNode.dataSource = self
}
required init?(coder aDecoder: NSCoder) {
fatalError("storyboards are incompatible with truth and beauty")
}
然後我設置我的ASTableNode:
func tableNode(tableNode: ASTableNode, nodeForRowAtIndexPath indexPath: NSIndexPath) -> ASCellNode {
let rowCount = 15
let node = ASTextCellNode()
node.text = String(format: "[%ld.%ld] says hello!", indexPath.section, indexPath.row)
return node
}
func numberOfSectionsInTableNode(tableNode: ASTableNode) -> Int {
return 1
}
func tableNode(tableNode: ASTableNode, numberOfRowsInSection section: Int) -> Int {
var count = 16
return count
}
問題是我編譯因爲Xcode中告訴我,我的控制器不符合協議「ASCommon TableViewDataSource」,使它工作的唯一方法是添加本機:
/*
@available(iOS 2.0, *)
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}*
/
任何想法,爲什麼它不工作我的項目,它是在AsyncdisplayKit的快速示例項目的工作? 感謝您的幫助。
需要符合協議。添加這個'numberOfRowsInSection'。 –
是的,但在例子迅速projet,它的工作。我想知道爲什麼。此外,還有func tableNode(tableNode:ASTableNode,numberOfRowsInSection部分:Int) - > Int {所以我不需要這個不是?可能在故事板上配置了 – user2206906
。 –