开发者

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 w开发者_开发百科hen displaying an image or pdf file i a 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
                //
               }
       }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜