Mat*_*ack 12 uitableview swift swift3
我已将代码更新为swift 3.0并在以下行中收到警告:
func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
Run Code Online (Sandbox Code Playgroud)
当我尝试将每个建议用@nonobjc静音警告或使其成为私有函数时,表不再加载.
错误如下:
实例方法'tableView(:cellForRowAtIndexPath :)'几乎匹配协议'UITableViewDelegate'的可选要求'tableView(:canFocusRowAt :)'
有谁知道导致此错误的原因以及如何解决?
非常感谢!
小智 20
只需将实现UITableViewDataSource协议的声明添加到类定义中,如下所示:
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {}
Run Code Online (Sandbox Code Playgroud)
在swift 3.0中,数据源的签名更改为:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
Run Code Online (Sandbox Code Playgroud)
注意之间的差异cellForRowAtIndexPath indexPath: IndexPath
和cellForRowAt indexPath: IndexPath
我正在使用新方法而没有任何警告,希望这将解决您的问题.
干杯.
归档时间: |
|
查看次数: |
5180 次 |
最近记录: |