1

I have an app with a transparent view controller over an opaque view controller. The opaque view controller has a button. I want to get the touches in the transparent view controller and log them, and also see the button clicked. Is that possible? When I try the nextResponder solution it doesn't work. When I print out the nextResponder I see it's the UIWindow, is that ok?

The AppDelegate simply does this:

OpaqueViewController *someVC = [[OpaqueViewController alloc] init];
someVC.view.frame = CGRectMake(0, 0, 320, 480);
[self.window addSubview:someVC.view];

TransparentViewController *panel = [[TransparentViewController alloc] init];
panel.view.frame = CGRectMake(0, 0, 320, 480);
[self.window addSubview:panel.view];

So I tried this:

@implementation TransparentViewController
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.nextResponder touchesBegan:touches withEvent:event];
}

And I can't get the button on the OpaqueViewController to click...

Community
  • 1
  • 1

1 Answers1

1

I know this an old question. Never the less I just struggled with the same problem. It seems that NextResponder is not the right approach on touches. Instead use:

[super touchesBegan:touches withEvent:event];

One would expect it to behave the same, but the super class most perform some additional magic.

EsbenB
  • 3,356
  • 25
  • 44