类型 'ViewController' 不符合协议
Type 'ViewController' does not conform to protocol
我正在学习 Swift 并遵循一些教程。我不断收到错误消息:
输入
'ViewController' does not conform with protocol
'UITableViewDataSource'
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var GetAllDataTest = NSMutableArray()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewWillAppear(_ animated: Bool) {
GetAllDataTest = FMDBDatabaseModel.getInstance().GetAllData()
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TestTableViewCell") as! TestTableViewCell
//cell.editData = self
cell.tag = indexPath.row
var l = Tbl_Test()
l = GetAllDataTest.object(at: indexPath.row) as! Tbl_Test
cell.lblName.text! = l.Name
cell.lblMobileNo.text! = l.MobileNo
cell.lblEmail.text! = l.Email
return cell
}
}
这是我目前尝试过的方法:
- 我已确保函数在 Class 中。
- 我已确保 ViewController 插座是主要故事板。
- 阅读其他具有类似问题的 Whosebug 问题,我找不到解决方案。 (我可能错过了)。
谢谢
您还需要实现其他方法。这里少了你
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return GetAllDataTest.count
}
我正在学习 Swift 并遵循一些教程。我不断收到错误消息: 输入
'ViewController' does not conform with protocol 'UITableViewDataSource'
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var GetAllDataTest = NSMutableArray()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewWillAppear(_ animated: Bool) {
GetAllDataTest = FMDBDatabaseModel.getInstance().GetAllData()
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TestTableViewCell") as! TestTableViewCell
//cell.editData = self
cell.tag = indexPath.row
var l = Tbl_Test()
l = GetAllDataTest.object(at: indexPath.row) as! Tbl_Test
cell.lblName.text! = l.Name
cell.lblMobileNo.text! = l.MobileNo
cell.lblEmail.text! = l.Email
return cell
}
}
这是我目前尝试过的方法:
- 我已确保函数在 Class 中。
- 我已确保 ViewController 插座是主要故事板。
- 阅读其他具有类似问题的 Whosebug 问题,我找不到解决方案。 (我可能错过了)。
谢谢
您还需要实现其他方法。这里少了你
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return GetAllDataTest.count
}