0
我对正在发生的事情感到困惑我在收集视图上做了一个教程,因为我对编程相当陌生,而且我相信我做的一切都正确,但是我碰到了-[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
。UITableView无法识别的选择器发送到实例
import UIKit
class ViewController: UIViewController, UITableViewDataSource {
var categories = ["Action", "Drama", "Science Fiction", "Kids", "Horror"]
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return categories[section]
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return categories.count
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! CategoryRow
return cell
}
它的工作!谢谢我将我的数据源直接设置为tableview而不是视图控制器 – Hightower98
最受欢迎的兄弟 –