In my application , used gallery concept. And this want to Zoom Image with double tap and using 2 finger. I used below code for this but its not working for me. i enable to achieve this functionality.. Please resolve my problem.
- (void)viewDidLoad
{
[self setupScrollView];
}
-(void) setupScrollView
{
//add the scrollview to the view
image_scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0,
self.view.frame.size.width,
self.view.frame.size.height)];
image_scroll.pagingEnabled = YES;
[image_scroll setAlwaysBounceVertical:NO];
//setup internal views
for (int i = 0; i < [self.PhotoImgArr count]; i++) {
current_page =(int)self.PhotoImgArr[i];
CGFloat xOrigin = i * self.view.frame.size.width;
AsyncImageView *image = [[AsyncImageView alloc] initWithFrame:
CGRectMake(xOrigin, 0,
self.view.frame.size.width,
self.view.frame.size.height)];
image.imageURL = [NSURL URLWithString:self.PhotoImgArr[i]];
image.contentMode = UIViewContentModeScaleAspectFit;
[image_scroll addSubview:image];
}
//set the scroll view content size
[image_scroll setShowsHorizontalScrollIndicator:NO];
[image_scroll setShowsVerticalScrollIndicator:NO];
[image_scroll setMaximumZoomScale:8.0];
self.image_view.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
image_scroll.decelerationRate = UIScrollViewDecelerationRateFast;
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTap setNumberOfTapsRequired:2];
[image_scroll addGestureRecognizer:doubleTap];
image_scroll.contentSize = CGSizeMake(self.view.frame.size.width *
self.PhotoImgArr.count,
self.view.frame.size.height);
//add the scrollview to this view
[self.view addSubview:image_scroll];
[image_scroll setZoomScale:[image_scroll minimumZoomScale]];
}
- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer {
if(image_scroll.zoomScale > image_scroll.minimumZoomScale)
[image_scroll setZoomScale:image_scroll.minimumZoomScale animated:YES];
else
[image_scroll setZoomScale:image_scroll.maximumZoomScale animated:YES];
}