3

I want to get CGPoint of a touch on UIWebview but I want to able to get exact same point when user hasnt zoomed yet and after zoomed.

So lets say user longtapped a point without zooming and below method returns point {185.5, 303} for that point, and after user zoomed and longtaps the same point,it becomes point {621, 397.5} on the screen

Basically I want to be able to get that point {621, 397.5} to be point {185.5, 303} when I zoom out.

I am not sure If I made it clear enough but hopefully you will understand my problem.

-(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;
}
SpaceDust__
  • 4,844
  • 4
  • 43
  • 82

0 Answers0