简体   繁体   中英

Programmatically changing zoom/pan in UIWebView

I am currently investigating the potential for programmatically adjusting the zoom level and on which area of the page the zoom is panned to. Is this possible either by manipulating the UIWebView or by firing custom javascript calls to the embedded browser?

I've looked around a lot for the same thing, and I haven't had a lot of luck. UIWebView is not descended from UIScrollView , so that type of manipulation is out. By the way, you probably don't mean to be asking about MobileSafari, since as a developer you don't have access to that programmatically. MobileSafari uses a UIWebView, not the other way around.

Good luck on figuring this one out! If you do, be sure to post the answer here. :)

You can programatically zoom the UIWebview by grabbing its UIScrollView and telling that to zoom. You can access the scrollview this way:

scrollView = [webView.subviews objectAtIndex:0];

After that you just manipulate the scrollview like you normally would. I just did this last week, and I have the zooming working correctly but it currently just zooms to the top left corner, so I'm still trying to figure out how to do centerpoint part of it. If you need any more help with the zooming let me know and I can try to explain it more.

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