Question

I'm trying to have my iPad app mirror the app's screen to a secondary screen via a VGA cable. Due to performance issues, I only want to have my view's displayed on the secondary screen, but still capture touch events via the iPad's screen.

My current method is with two UIWindows: one for the VGA-connected screen that shows all the views, animations etc. and another UIWindow for the iPad screen which captures touch events. This works great performance-wise and I can log the touch events received on the iPad screen.

But for some reason I cannot pass the touchesBegan:, touchesEnded: etc methods to my UIViewControllers and have them react correctly. If I send it straight to the UIViewController I can capture them by overriding the touch events on the UIViewController but that's only useful for capturing touches on the background, not for buttons etc that are added to the UIViewController.

Then I tried sending the touch events to viewController.view and they disappear somewhere else. I even tried looping through each subview in the view controller and still no dice.

I must be missing something simple, any ideas?

Was it helpful?

Solution

I have had this problem too. Your problem can be solved very simply. You can just overwrite the UIView's hitTest method, like this:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent*)event
{
  return [[[[UIApplication sharedApplication] delegate] secondWindow] hitTest:point withEvent:event];
}

and you can pass the touch event to the other view. My problem is harder than yours. I want to "copy" the event, not only "passing" it. Does any one know how to do this?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top