尝试在 swift 3 中第一次使用 AsyncdisplayKit。
有一点我不明白:
我只是设置了我的 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 的快速示例项目上运行吗?谢谢你的帮助。