如何在ios中从缩放图像中缩小

如何在ios中从缩放图像中缩小,ios,objective-c,uiscrollview,Ios,Objective C,Uiscrollview,我有这样的代码 在loadView()中 我已经创建了这样的scrollview,带有点击次数和最大值 self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; self.scrollView.delegate = self; self.scrollView.maximumZoomScale = 2; self.scrollView.autoresizingMask = self.view.autoresiz

我有这样的代码

在loadView()中

我已经创建了这样的scrollview,带有点击次数和最大值

self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
self.scrollView.delegate = self;
self.scrollView.maximumZoomScale = 2;
self.scrollView.autoresizingMask = self.view.autoresizingMask;
[self.view addSubview:self.scrollView];

UITapGestureRecognizer *tapOnce = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[tapOnce setNumberOfTouchesRequired:1];
[doubleTap setNumberOfTapsRequired:2];
[tapOnce requireGestureRecognizerToFail:doubleTap];

[self.scrollView addGestureRecognizer:tapOnce];
[self.scrollView addGestureRecognizer:doubleTap];
方法实现:

- (void) handleSingleTap:(UIGestureRecognizer *)gestureRecognizer
{
//single tap in full screen mode it will dismiss the view
  [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer 
{
//double tap will zoom the view to scrollview max value
  [self.scrollView setZoomScale:self.scrollView.maximumZoomScale animated:NO];   
}
现在我可以在点击全屏图像时“缩放”,它将进入最大缩放值,但如何在双击时从缩放到最小值,因为我有功能在单次点击时关闭视图。我需要在“handledoubleTap”方法本身中再处理一次双击

- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer 
{
    if ( flag == 1 ){
        flag = 0;
        [self.scrollView setZoomScale:self.scrollView.maximumZoomScale animated:NO];   
    }
    else {
        flag = 1;
        [self.scrollView setZoomScale:self.scrollView.minimumZoomScale animated:NO];   
    }

}

在上述方法中,只需根据需要设置标志。希望这有帮助:)

谢谢。。这对我有用。。但我不能缩放触摸位置,它只是缩放到最大值,我需要像全屏触摸位置应该缩放。。。有人能告诉我怎么做吗