0

I have an ImageView, and Images URL in array. I want to download and show these images on UIImageView, but issue this that I am facing Two Gestures on that View, so inner Gesture which is on only ImageView is not looking to work.

My code is like below

  [self.imageView setUserInteractionEnabled:YES];


            UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
            UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];

            // Setting the swipe direction.
            [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
            [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];

            // Adding the swipe gesture on image view
            [self.imageView addGestureRecognizer:swipeLeft];
            [self.imageView addGestureRecognizer:swipeRight];





- (void)handleSwipe:(UISwipeGestureRecognizer *)swipe {

    if (swipe.direction == UISwipeGestureRecognizerDirectionLeft) {
        NSLog(@"Left Swipe");

    }
    if (swipe.direction == UISwipeGestureRecognizerDirectionRight) {
        NSLog(@"Right Swipe");

    }
}

The method handleSwipe is not called and also when I move it opens side menu, as there is Gesture applied same as facebook side menu opens in its iOS app.

How can I change images in ImageView when whole parent view is also using Gesture.

Thanks

4

1 回答 1

0

尝试这个。它解决了两个 ypur 问题

[self.imageView setUserInteractionEnabled:YES];


        UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleLeftSwipe)];
        UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleRightSwipe)];

        // Setting the swipe direction.
        [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
        [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];

        // Adding the swipe gesture on image view
        [self.imageView addGestureRecognizer:swipeLeft];
        [self.imageView addGestureRecognizer:swipeRight];





- (void)handleLeftSwipe
{
    NSLog(@"Left Swipe");
}

- (void)handleRightSwipe
{
    NSLog(@"Left Swipe");
}
于 2013-11-06T09:34:47.333 回答