好的,我们有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或其他任何你喜欢的东西.
原文链接:/swift/319059.html确实可以称之为委托但是嘿!