0

尝试在 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 的快速示例项目上运行吗?谢谢你的帮助。

4

1 回答 1

0

第一:你需要把你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 是否没有关联的视图控制器,如果是,则只清除该字段。

第三:不要忘记在你的项目中安装 pod。

于 2017-02-16T01:30:50.627 回答