Ios 获取Xcode类型“中的错误”;“视图控制器”;不符合协议”的规定;UITableViewDataSource“;
我正试图学习table views教程,但在我的类声明行中出现了一个错误,它说:“类型“ViewController”不符合协议“UITableViewDataSource”。下面是我的代码:Ios 获取Xcode类型“中的错误”;“视图控制器”;不符合协议”的规定;UITableViewDataSource“;,ios,xcode,swift,uitableview,Ios,Xcode,Swift,Uitableview,我正试图学习table views教程,但在我的类声明行中出现了一个错误,它说:“类型“ViewController”不符合协议“UITableViewDataSource”。下面是我的代码: import UIKit class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { private let dwarves = ["Sleepy", "Sneezy", "Bashf
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
private let dwarves = ["Sleepy", "Sneezy", "Bashful", "Happy", "Doc", "Grumpy", "Dopey", "Thorin", "Dorin", "Nori", "Ori", "Balin", "Dwalin", "Fili", "Kili", "Oin", "Gloin", "Bifur", "Bofur", "Bombur"]
let simpleTableIdentifier = "SimpleTableIdentifier"
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier(simpleTableIdentifier) as? UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: simpleTableIdentifier)
}
cell!.textLabel!.text = dwarves[indexPath.row]
return cell!
}
}
您错过了func
tableView(tableView:UITableView,numberofrowsinssection-secion:Int)->Int{}
这对于tableview是必需的
因此,只需在代码中添加以下内容:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return count(dwarves)
}
您错过了func
tableView(tableView:UITableView,numberofrowsinssection-secion:Int)->Int{}
这对于tableview是必需的
因此,只需在代码中添加以下内容:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return count(dwarves)
}
您错过了func
tableView(tableView:UITableView,numberofrowsinssection-secion:Int)->Int{}
这对于tableview是必需的
因此,只需在代码中添加以下内容:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return count(dwarves)
}
您错过了func
tableView(tableView:UITableView,numberofrowsinssection-secion:Int)->Int{}
这对于tableview是必需的
因此,只需在代码中添加以下内容:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return count(dwarves)
}
数据源协议缺少必需的方法:tableView:numberOfRowsInSection:
请参阅:您缺少数据源协议所需的方法:tableView:numberOfRowsInSection:
请参阅:您缺少数据源协议所需的方法:tableView:numberOfRowsInSection:
请参阅:您缺少数据源协议所需的方法:tableView:numberOfRowsInSection:
请参阅:UITableViewDataSource有两个必需的方法:
tableView:cellForRowAtIndexPath:
及
两者都需要实施
你错过了第二个
您可以在此处找到有关UITableViewDataSource的更多信息:UITableViewDataSource有两个必需的方法:
tableView:cellForRowAtIndexPath:
及
两者都需要实施
你错过了第二个
您可以在此处找到有关UITableViewDataSource的更多信息:UITableViewDataSource有两个必需的方法:
tableView:cellForRowAtIndexPath:
及
两者都需要实施
你错过了第二个
您可以在此处找到有关UITableViewDataSource的更多信息:UITableViewDataSource有两个必需的方法:
tableView:cellForRowAtIndexPath:
及
两者都需要实施
你错过了第二个
您可以在此处找到有关UITableViewDataSource的更多信息:您必须添加此函数-
func tableView(tableView:UITableView,numberOfRowsInSection:Int)->Int
,因为它是必需的函数UITableViewDataSource
您必须添加此函数-func tableView(tableView:UITableView,numberOfRowsInSection:Int)->Int
因为它是必需的函数UITableView数据源
您必须添加此函数-func tableView(tableView:UITableView,numberOfRowsInSection:Int)->Int
因为它是一个必需的函数UITableViewDataSource
您必须添加此函数-func tableView(tableView:UITableView,numberOfRowsInSection:Int)->Int
因为它是必需的函数UITableViewDataSource