Ravi Raman
Ravi Raman

Reputation: 1070

open an image from a scrollview into a new viewcontroller

I have a UIScrollView which contains multiple UIImageViews.

I want to know which UIImageView was tapped from the scrollview.

Thanks

Upvotes: 0

Views: 359

Answers (1)

NeverBe
NeverBe

Reputation: 5038

Add gesture recognizer to image view and then open it in view controller (modal)

Use UIGestureRecognizerDelegate delegate

UITapGestureRecognizer *gestureTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];
gestureTap.delegate = self;
gestureTap.numberOfTapsRequired = 2;
[image addGestureRecognizer:gestureTap];
[gestureTap release];



- (void)doubleTap:(UIPanGestureRecognizer *)gesture {
    NSLog(@"double tap on %@", gesture.view);

}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    return YES;
}

Upvotes: 1

Related Questions