0

我想知道如何停止我的 sublass o UIScrollView 无法正常工作:

- (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?
    }

}

我只希望它在它有 2 触动我不想做的所有其他事情时采取行动。或者更好的是,如果你能告诉我如何将 else 语句中的触摸传递给 UIView:

UntitledViewController.otherView

如果你能告诉我如何做到这一点,那么我会很高兴。

4

1 回答 1

0

您要覆盖的方法实际上返回一个 BOOL 值,该值告诉 scrollView 是否处理触摸。所以实际的实现应该更像:

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

现在,当它不处理触摸时,它应该自动将它们传递给下一个响应者,它应该是你的UntitledViewController.otherView.

于 2010-02-05T23:47:48.450 回答