I have created a uiview subclass, and instantiated it (lets call it the master view). This uiview subclass contains it’s own gesture recognizers and touch event overrides as well as the animations corresponding to these touch events (e.g. rotation and flipping).
I would like to create another instantiation of this subclass (or similar subclass) that we will call the slave view. The slave view should be identical to the master in appearance, but will not respond to touch events itself. Instead, the slave should in essence be a remote controlled drone that animates in lock step with master view.
I was trying to get my brain around how to do this… it seems that maybe I could create a slave subclass such that the master can call animation delegate methods for the slave view. So every animation call in the Master would also call a method in the slave with the same transform.
The parent view will have multiple master-slave pairs, each master-slave pair animated independently. I really prefer not to move the gesture-recognizers and animation to the parent level.
Any thoughts on a code pattern for this master-slave pair? My understanding of calling delegates might be challenged, but I get the feeling that delegate methods will not work here when I go to more than one master/slave pair?
Which object creates the slave? The parent view or the master? If you have master create its own slave, then it can set itself as the delegate of the slave. There shouldn’t be any trouble with having multiple pairs, because each master will be the delegate of a specific instance of the slave class.