加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在Swift中委托不同类型的属性

发布时间:2020-12-14 05:23:59 所属栏目:百科 来源:网络整理
导读:好的,我们有UIScrollView声明: protocol UIScrollViewDelegate: NSObjectProtocol { ... }class UIScrollView: UIView { ... weak var delegate: UIScrollViewDelegate? ...} 然后UITableView与委托变体? protocol UITableViewDelegate: NSObjectProtocol,
好的,我们有UIScrollView声明:
protocol UIScrollViewDelegate: NSObjectProtocol { ... }
class UIScrollView: UIView {
    ...
    weak var delegate: UIScrollViewDelegate?
    ...
}

然后UITableView与委托变体?

protocol UITableViewDelegate: NSObjectProtocol,UIScrollViewDelegate { ... }
class UITableView: UIScrollView {
    ...
    weak var delegate: UITableViewDelegate?
    ...
}

Apple如何做到这一点?当我做我的

protocol MyScrollViewSubclassDelegate: NSObjectProtocol,UIScrollViewDelegate { ... }
class MyScrollViewSubclass: UIScrollView {
    ...
    weak var delegate: MyScrollViewSubclassDelegate?
    ...
}

我使用’MyScrollViewSubclassDelegate’类型获得Property’委托’不能覆盖类型为“UIScrollViewDelegate?”的属性.

我偶然发现了几次,我找到的唯一解决方法就是将我的财产称为customDelegate或其他任何你喜欢的东西.

确实可以称之为委托但是嘿!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读