0

I am using the word "subservient" as I don't know the correct term. I have tried various things to make the my UIScrollView the last gesture to be checked, so that gestures that belong to subviews of the scroll view will fire before or instead of the scrollview.

For example I have a scroll view that contains a subview, which has a pan gesture recognizer. When I try to pan, sometimes the scroll view's pan fires, sometime the sub view's pan gesture fires. I want the subview's gesture to fire consistently instead of the scroll view if that view is directly dragged.

4

1 回答 1

0

您是否尝试将滚动视图的“delaysContentTouches”属性设置为 true?

或者您可以继承 UIScrollVeiw 并覆盖 touchesShouldCancelInContentView: 方法,如下所示:

-(BOOL)touchesShouldCancelInContentView:(UIView *)view
{

    if ([view isKindOfClass:[UIButton class]]) {//or whatever class you want to override
        return YES;
    }

    if ([view isKindOfClass:[UIControl class]]) {
        return NO;
    }

    return YES;
}
于 2013-10-23T10:43:10.153 回答