Search code examples
iphonexcodemodalviewcontrollertouchesbegan

Modal views and touchesBegan


This question is a follow on from the following:

UITouch - Event not responding

I done more research and I know what the problem is, but I don't know how to solve it or even if it can be solved. I may have to take a new approach.

I have a RootViewController and from this I load a second ViewController using the following code:

[self presentModalViewController:newWorkoutViewController animated:YES];

I then have the following code in place in NewWorkoutViewController:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"New Workout Screen tapped");
}

This method is not being actioned, I think this is because its a modal view. Is there anyway to detect taps on the screen in a modal view.

Thanks Stephen


Solution

  • Define the relevant methods on your view controller, not on your view.