2016-11-24 47 views
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的快速示例項目的工作? 感謝您的幫助。

+0

需要符合協議。添加這個'numberOfRowsInSection'。 –

+0

是的,但在例子迅速projet,它的工作。我想知道爲什麼。此外,還有func tableNode(tableNode:ASTableNode,numberOfRowsInSection部分:Int) - > Int {所以我不需要這個不是?可能在故事板上配置了 – user2206906

+0

。 –

回答

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 
} 

*視圖控制器()是你的控制器包含表的名稱。

其次:檢查您的MainStoryboard是否沒有關聯視圖控制器,如果是,只清除該字段。

第三:不要忘記在您的項目中安裝吊艙。