views:

370

answers:

1

I want to know how I would stop my sublass o UIScrollView is not working properly:

- (void) touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view {

    if ([touches count] == 2) {

        [super touchesShouldBegin:[touches anyObject] withEvent:event inContentView:view];
    }
    else {
        //How do I stop it completely from using one touch?
    }

}

I only want it to act when it has 2 touches everything else I want to do nothing. Or even better, if you can tell me how to pass the touches in the else statement to a UIView:

UntitledViewController.otherView

If you can tell me how to do this then I would be so happy.

A: 

The method you are overriding actually returns a BOOL value that tells the scrollView to handle the touches or not. So the actual implementation should be more like:

- (BOOL) touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view {
    if ([touches count] == 2) {
        return YES;
    }
    else {
        return NO;
    }
}

Now, when it does not handle the touches, it should automatically pass them to the next responder, which should be your UntitledViewController.otherView.

Dimitris