表格检视cellForRowAtIndexPath警告 [英] Table View cellForRowAtIndexPath warning
问题描述
我已将代码更新为swift 3.0,并在以下行收到警告:
I have updated my code to swift 3.0 and get a warning on the following line:
func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
当我尝试使用每个建议以@nonobjc消除警告或将其设为私有功能时,表将不再加载.
When I try each of the suggestions to either silence the warning with @nonobjc or make it a private function the table no longer loads.
该错误显示为:
实例方法'tableView(:cellForRowAtIndexPath :)'与协议'UITableViewDelegate'的可选要求'tableView(:canFocusRowAt :)'几乎匹配
Instance method 'tableView(:cellForRowAtIndexPath:)' nearly matches optional requirement 'tableView(:canFocusRowAt:)' of protocol 'UITableViewDelegate'
有人知道导致此错误的原因以及如何解决该错误吗?
Does anyone know what causes this error and how to fix it?
非常感谢!
推荐答案
只需将实现 UITableViewDataSource 协议的声明添加到这样的类定义中:
Just add the declaration of implementing UITableViewDataSource protocol to the class definition like this:
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {}
这篇关于表格检视cellForRowAtIndexPath警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!