获取缩放的UIWebView缩放触摸点

时间:2014-04-11 16:47:55

标签: ios objective-c uiwebview uitapgesturerecognizer cgpoint

我想在UIWebview上获得CGPoint的触摸,但是当用户还没有缩放并且在缩放之后我希望能够获得完全相同的点。

因此,假设用户使用了一个没有缩放的点并且下面的方法返回point {185.5, 303}该点,并且在用户缩放并长按相同点之后,它在屏幕上变为point {621, 397.5}

基本上我希望在缩小时能够point {621, 397.5}point {185.5, 303}

我不确定如果我说得够清楚但希望你能理解我的问题。

-(void)onLongTap:(UILongPressGestureRecognizer *)recognizer
{
    NSLog(@"Double Tap");
    // Get the specific point that was touched
    if(self.zoomScale - 1.0 < 0.001 && self.zoomScale - 1.0 > - 0.001) {
        // Not zooming
        CGPoint point = [recognizer locationInView:webView];
        NSLog(@"point %@ ",NSStringFromCGPoint(point));
    }
    else
    {
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            self.zoomScale = 1.0f;
            [webView.scrollView setZoomScale:self.zoomScale animated:YES];

        });

        dispatch_async(dispatch_get_main_queue(), ^(void) {
            CGPoint point = [recognizer locationInView:webView];
            NSLog(@"point zoom reversed %@ ",NSStringFromCGPoint(point));
        });
    }
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale{
    self.zoomScale *= scale;
}

0 个答案:

没有答案