質問

How can I make it so that when I use my UIScrollView the pan gesture recognizer selector is not called.

I want to be able to scroll in the scroll view without the pan gesture selector being called.

Here is my pan detected function:

- (void)panDetected:(UIPanGestureRecognizer *)panRecognizer
{

    CGPoint translation = [panRecognizer translationInView:self.view];
    CGPoint imageViewPosition = self.draggableImage.center;
    imageViewPosition.x += translation.x;
    imageViewPosition.y += translation.y;

    self.draggableImage.center = imageViewPosition;
    [panRecognizer setTranslation:CGPointZero inView:self.view];
}

I do not want it to be called when I am using my UIScrollView at the bottom of the page.

役に立ちましたか?

解決

you could remove the gesture recognizer from the scroll view

NSArray* gestureRecognizers = [scrollView gestureRecognizers];
for (UIGestureReconizer* recog in gestureRecognizers) {
    if ( [recog isKindOfClass:[UIPanGestureRecognizer Class]] )
        [recog removeTarget:scrollView.delegate action:@selector(scrollViewDidScroll:)];
}

I don't understand why this is needed to be done, but here it is.

他のヒント

Not exactly sure what you're trying to accomplish here. I haven't played with this, but my initial thought is that if you disable the pan recognizer, your scroll view isn't gonna scroll. Your scrollview calculates where and how to scroll based on the what the pan recognizer is telling it.

If you have an alternative setup to handle the scrolling, then by all means:

UIScrollView *scrollView;
[[scrollView panGestureRecognizer] setEnabled:NO];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top