【发布时间】:2019-07-20 20:31:27
【问题描述】:
类型‘TVViewController’不符合协议‘UITableViewDataSource’
我对编程还很陌生,而且错误非常模糊,所以我不知道从哪里开始排除故障。
class WeeksViewController: UIViewController, UITableViewDataSource {
//Categories
var categories = ["One", "Two", "Three", "Four", "Five", "Six", "Seven"]
//Number of sections
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return categories.count
}
//Defining the headers
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return categories[section]
}
//Number of rows
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
//Cell as identifier & category as the class
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! CategoryRow
return cell
}
}
【问题讨论】:
标签: swift uitableview uicollectionview