尝试使用AsyncdisplayKit第一次在斯威夫特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的快速示例项目上工作吗?谢谢你的帮助。
发布于 2017-02-16 01:30:50
首先:您需要将您的ViewController()放在AppDelegate中
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
window.backgroundColor = UIColor.white
window.rootViewController = UINavigationController(rootViewController: ViewController());
window.makeKeyAndVisible()
self.window = window
return true
}*ViewController()是包含表的控制器的名称。
第二:检查您的MainStoryboard是否没有与视图控制器关联的视图控制器,如果是,则只清除该字段。
第三:不要忘记在你的项目中安装吊舱。
https://stackoverflow.com/questions/40783013
复制相似问题