views:

6084

answers:

3

I'm displaying a series of tiled images in a UIWebView and would like to programmatically set the UIWebview's initial zoom and view location.

How does one go about doing so?

A: 

It doesn't look like there's a documented way to do what you want. An alternative that only half solves your problem is using a UIScrollView. You could put UIImageViews inside your UIScrollView and then scroll to any position in the scroll view. This does not allow you to programmatically zoom the view though. If it's something you think should be added to the SDK file a radar: http://bugreport.apple.com/

Andy Bourassa
+2  A: 

Programmatic scrolling of UIScrollView is now a solved problem. I have a detailed discussion of how (and why) UIScrollView zooming works, an example project and ZoomScrollView class that encapsulates the required zooming magic at github.com/andreyvit/ScrollingMadness/.

So probably you should put your images inside UIScrollView like Andy advised.

Andrey Tarantsov
You are totally right. In the time from when I asked my question to now I ended up doing it in a manner similar (not as complete) to your "ScrollingMadness".
Mike
So, how does this help scroll an UIWebView and set a zoom level?
kudor gyozo
+2  A: 

Set attribute scalesPageToFit of UIWebView to YES. Then the webpage is scaled to fit and the user can zoom in and zoom out.

Richard Chen