Working with One Xib with Multiple Classes

后端 未结 1 1032
粉色の甜心
粉色の甜心 2021-01-28 11:25

I have already asked a question here Handling Multiple Xib or Fixing collapse and expand button on multiple Xib file then I thought to stop using multiple xib and only main xib

相关标签:
1条回答
  • 2021-01-28 11:50

    Yes it is possible using polymorphism. This is the idea that multiple classes can be sent the same message, (and potentially behave in different ways). You can create a class like: BaseViewController that would have the definition for btnPupl:(id)sender in the @interface. This way any view controller that inherits from BaseViewController will inherit btnPupl:(id)sender.

    Another option (I'd go with the first one) is to subclass UIButton and implement the behaviour you want in that subclass.

    0 讨论(0)
提交回复
热议问题