iphone uiwebview programmatic zoom

早过忘川 提交于 2019-11-29 12:46:57

get the UIWebview's subview which is a UIScrollview

UIScrollView *sview = [[webview subviews] objectAtIndex:0];

Then use zoom methods on that.

This is the only way I could find to accomplish it: (specify your own sizes if you wish, i was attempting to zoom out after typing into a form field)

UIScrollView *sv = [[webViewView subviews] objectAtIndex:0]; [sv zoomToRect:CGRectMake(0, 0, sv.contentSize.width, sv.contentSize.height) animated:YES];

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
            //
        }
    }
}

From this subclass of UIWindow use a delegate or Notification to catch the tap on your class.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!