[英]Which is the good way to conforms to UITableView protocols?
I am following this guideline to implement UITableView
protocols. 我正在遵循此准则来实现UITableView
协议。 But right now, it's showing me an error, what I am doing wrong? 但是现在,它向我显示了一个错误,我在做什么错?
'RequestsViewController' does not conform to protocol 'UITableViewDataSource'. 'RequestsViewController'不符合协议'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) {
}
}
CHANGE THIS 改变这个
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> RequestsTableViewCell
TO: 至:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.