Multiple delegates per one object?

后端 未结 5 2028
无人共我
无人共我 2020-12-25 14:54

I have a UIScrollView that I need to subclass and within the subclass I need to attach the UIScrollViewDelegate so I can implement the viewFo

5条回答
  •  礼貌的吻别
    2020-12-25 15:22

    I don't think you can have two UIScrollViewDelegate delegates directly connected to the same object.

    What you can do is having the two delegates chain-connected. I.e., you connect one delegate to the other, then have the former forward messages to the latter when it cannot handle them itself directly.

    In any case, I think I am missing a bit to fully suggest a solution, namely the reason why you do need a second delegate and cannot do always through one single delegate. In other words, what I think is that there might be alternative designs that would avoid needing two delegates.

提交回复
热议问题