views:

44

answers:

1

Hi,

I have an image encoded in BASE64 which I retrieve from a server and than load into a UIWebView with :

[webViewer loadData:[NSData decodeBase64ForString:imageData] MIMEType:@"image" textEncodingName:@"ASCII" baseURL:nil];

The image loads fine but when the image is bigger than my webviewer, the user cannot zoom in and out by pinching the iphone like in all other UIWebView documents.

The user can move the picture around to see the whole picture but since they cannot zoom out, they cannot see the whole picture in the size of the UIWebView frame.

Does anyone have a solution to this problem. Thanks.

+1  A: 

add this to your webview HTML, basically use an image tag and place the meta tag in the HTML String

NSString * header = @"<meta name='viewport' content='width=320; initial-scale=1.0; maximum-scale=2.0; user-scalable=1;'/>"
NSString * html = [NSString stringWithFormat:@"<html>%@<img src='%@'/></html>",header,imageData]
[webView loadHTMLString:html baseURL:nil];
Aaron Saunders
Aaron thanks for the advice but there is no HTML. In this case loadData is loading the raw image data into a UIWebView.
@user427034 try this new approach, see edits
Aaron Saunders