ダブルタップの判定として、numberOfTapsRequired = 2とします。
メソッド側にてscrooViewのサイズを変更させます。
- (void)viewDidLoad
{
[super viewDidLoad];
UITapGestureRecognizer *doubleTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(doubleTap:)];
doubleTap.numberOfTapsRequired = 2;
[self.view addGestureRecognizer:doubleTap];
}
- (void)doubleTap:(UITapGestureRecognizer *)recognizer {
CGPoint location = [recognizer locationInView:[recognizer.view superview]];
CGRect zoomRect;
if (self.scrollView.zoomScale > 1.0) {
zoomRect = self.scrollView.bounds;
} else {
zoomRect = [self zoomRectForScrollView:self.scrollView
withScale:2.0
withCenter:location];
}
[self.scrollView zoomToRect:zoomRect animated:YES];
}
0 件のコメント:
コメントを投稿