覆盖非动态类delaration [英] Override non-dynamic class delaration

查看:733
本文介绍了覆盖非动态类delaration的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用新的Xcode 8.3,我收到错误:

With new Xcode 8.3, I get error :


无法覆盖扩展中的非动态类声明

Cannot override a non-dynamic class declaration from an extension

代码行

 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

如何避免此警告?

推荐答案

这意味着,您不能在扩展中覆盖超类委托方法。
你可以做的是mv扩展覆盖方法到子类声明。

which means, you can't not override like super class delegate method in extension. the way you can do is mv extension override method to subclass declare.

final class DEMO, UITableViewDataSource, UITableViewDelegate { 
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
    return sectionHeader
}

override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 40
}

}

这篇关于覆盖非动态类delaration的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆