views:

76

answers:

1

Hi, I have a map image in a uiwebview. It default loads in the top left hand corner. I would like it to initialize in the center of the uiwebview.

Does anyone know how to do this?

Thanks!

+2  A: 

If the map image is the only thing in the page, is it wrapped in an html page? If it is at least wrapped in a body tag you could do the following:

NSString *bodyStyle = @"document.getElementsByTagName('body')[0].style.textAlign = 'center';";
NSString *mapStyle = @"document.getElementById('mapid').style.margin = 'auto';";

[webView stringByEvaluatingJavaScriptFromString:bodyStyle];
[webView stringByEvaluatingJavaScriptFromString:mapStyle];

Let me know how exactly your html is structured and then I can provide some more information if necessary.

rickharrison
However it's displayed, the easiest (and pretty much only) way to interface with a UIWebView is through javascript
Ed Marty