I am trying to "mirror" a view controller:
- application launches view controller 1 (class A)
- the application launches view controller 2 (also class A) on another UIWindow (external display, via Airplay or a physical connector).
- any touch event received by controller 1 must be played on view controller 2
I have some of this work on things like MkMapViewssimple view controllers, just by catching things like changing a region or scrolling in vc1 and tell vc2 to set up your region or scrolling to that position, having UIControl IBActions on vc1 also call same action in vc2 etc.
This works with simple cases, but the problem is with complex view controllers that have things like UITableViewscustom ones UITableViewCellsthat expand / contract, etc. I need to implement every possible delegate / action and make a bunch of objects aware of things that they shouldn't know about, which just seems wrong if I'm going to do it all over again.
I tried going through the subview vc1 tree and using objc_setAssociatedObject()it to connect the UIRs in the view controller instances with each other, but I still need to catch every delegate / action on vc1 to find UIResponderon vc2 to simulate the event. There should be an easier way to do this. I tried to subclass UIWindowand redefine sendEventand send the event to an external display UIWindow, but everyone UIEventseems to have information in it that links it UIWindowto where it was created, because the external display UIWindowdid nothing with it when I sent it.
, - , ? swizzling UIView touch, , , UITouches UIEvents UIWindow, , UIEvent, , .
. , , Airplay , , . , iPhone- ( ), , (, , , HDTV).
?