ダブルタップでタップした箇所をズームする機能を実装したいのですが、scrollViewに乗せたUIImageViewをズームできません。
(参考サイトはこちらです。)
http://cocoadays.blogspot.jp/2010/09/3.html
imageViewをズームさせるにはどのようにすれば良いでしょうか?
- (void)viewDidLoad {
scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
scrollView.frame = self.view.bounds;
scrollView.backgroundColor = [UIColor blueColor];
scrollView.conteimgViewntSize = CGSizeMake(imgView.bounds.size.width+100, imgView.bounds.size.height);
scrollView.frame = CGRectMake(0,50,320,500);
scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
scrollView.pagingEnabled = YES;
scrollView.bouncesZoom = YES;
scrollView.minimumZoomScale = 1.0;
scrollView.maximumZoomScale = 2.0;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
[self.view addSubview:scrollView];
img =[UIImage imageNamed:[NSString stringWithFormat:@"a.jpg"]];
imgView = [[UIImageView alloc]initWithImage:img];
imgView.frame = CGRectMake(0, 0, self.view.frame.size.width, 448);
imgView.userInteractionEnabled = YES;
[scrollView addSubview:imgView];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch* touch = [touches anyObject];
if ([touch tapCount] == 2) {
scrollView = (UIScrollView*)self.view;
CGRect zoomRect;
if (scrollView.zoomScale > 1.0) {
zoomRect = scrollView.bounds;
} else {
zoomRect = [self zoomRectForScrollView:scrollView
withScale:2.0
withCenter:[touch locationInView:nil]];
}
[scrollView zoomToRect:zoomRect animated:YES];
}
}