我正在关注 this实现 UITableView
协议(protocol)的指南。但是现在,它向我显示错误,我做错了什么?
'RequestsViewController' does not conform to protocol 'UITableViewDataSource'.
class RequestsViewController: UIViewController {
...
...
}
extension RequestsViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrayRequests.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 100
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> RequestsTableViewCell {
let cell:RequestsTableViewCell = (tableView.dequeueReusableCell(withIdentifier: cellIdentifier) as! RequestsTableViewCell)
//Doing some assignments.
return cell
}
}
extension RequestsViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
}
最佳答案
改变这个
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> RequestsTableViewCell
收件人:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
关于ios - 哪个是符合 UITableView 协议(protocol)的好方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44941062/