开发者

Programmatically changing zoom/pan in UIWebView

I am currently investigating the po开发者_C百科tential 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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜