Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 获取Xcode类型“中的错误”;“视图控制器”;不符合协议”的规定;UITableViewDataSource“;_Ios_Xcode_Swift_Uitableview - Fatal编程技术网

Ios 获取Xcode类型“中的错误”;“视图控制器”;不符合协议”的规定;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

我正试图学习table views教程,但在我的类声明行中出现了一个错误,它说:“类型“ViewController”不符合协议“UITableViewDataSource”。下面是我的代码:

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