0
votes

I'm working on iPad app. My UIViewController contains only a custom UIView with a size of 500wx500h.

I implemented the touches methods both in the UIViewController and the custom UIView in order to call the UIViewController touches methods when we touch all around the custom UIView and call the custom UIView touches methods when we touch inside it.

UIViewController touchesMoved :

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint point = [touch locationInView:self.view];

    NSLog(@"TEST"); // Added during edition
    if (!CGRectContainsPoint(self.drawingView.frame, point)) {
        NSLog(@"UIVIEWCONTROLLER");
    }

}

Custom UIView touches Moved :

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"CUSTOM VIEW");
}

When I'm touching the custom UIView moving my finger, CUSTOM VIEW is logged until I removed the finger on the screen. On the other hand, when I'm touching outside of the custom UIView, the UIVIEWCONTROLLER is called only one time in the touchesMoved method.

Am I missing something wrong ?

EDIT : I added a log in my UIViewController touchesMoved method. When I touch inside the custom view, it logs the TEST during all the touching phase. But when I touch outside, I get the same behaviour.

2
what is drawingView? you said that your controller has just got one view, but it should have at least two: self.view and drawingView... could it be the former is hijacking the touches? - sergio
My UIViewController contains his own view and an other custom UIView (which is called drawingView). - Seb

2 Answers

0
votes

add exclusiveTouch property to your view to disable multi touches

your view.exclusiveTouch=YES;
0
votes

There is some likeliness that your self.view is intercepting touches and handling them, so they will not make it through to the view controller. You could try doing either of 2 things (or both) and see if it works:

  1. self.view.exclusiveTouch = NO;

  2. self.view.userInteractionEnabled = NO;

I would also try to call [super touchesMoved: touches withEvent: event];

Hope it helps.