ios - Swift: UIScrollViewDelegate extension -
can use protocol extensions uiscrollviewdelegate offer default implementation of scrollviewdidscroll
views conforms protocol?
because want able in single file propagate same scrollviewdidscroll implementations through other views, without having implement method in each view, 6.
what worked me implement extension on type implementing protocol, i.e. uiviewcontroller
extension uiviewcontroller{ func scrollviewdidscroll(scrollview: uiscrollview){ //do print("scrolled\n") } }
in swift 2.0 only: seems should able below doesn't seem work:
extension uiscrollviewdelegate{ func scrollviewdidscroll(scrollview: uiscrollview){ //do } }
any implementation of scrollviewdidscroll write in type conforms protocol believe should overwrite implementation.
Comments
Post a Comment