简体   繁体   中英

zoom in on a uiwebview by taping?

In Safair mobile you can zoom in by double taping if you have a html page that you display. But if you use a uiwebview and display an image or pdf file you have to pinch open to zoom.

My question is: what do I have to do to get double tap to work when displaying an image or pdf file ia uiwebview?

Can you make the uiwebview a sub view under a uiscrollview, will you then be able to double tap an zoom? And how would you do that?

What a double tap in Mobile Safari really does is focus on the content. It will find the div or section on the web page that you tapped on and then zoom to focus. It is not simply 'double tap to zoom'.

To get double tap from UIWebview u need to subclass the UIWindow and use the method,

- (void)sendEvent:(UIEvent *)event {
    NSLog(@"tap detect");
    NSArray *allTouches = [[event allTouches] allObjects];
    UITouch *touch = [[event allTouches] anyObject];
    UIView *touchView = [touch view];

    if (touchView && [touchView isDescendantOfView:urWebview]) {
        //
        // touchesBegan
        //
               if(touch.tapCount==2){
                     //
                // doubletap
                //
               }
       }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM