Image cannot be enlarged when loading in UIWebView

I have an image encoded in BASE64 that I retrieve from the server and upload to UIWebView with:

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

The image loads fine, but when the image is larger than my webview, the user cannot zoom in by pinching the iphone, as in all other UIWebView documents.

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

Does anyone have a solution to this problem. Thank.

+3
source share
1 answer

- HTML, HTML

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];
+3

Source: https://habr.com/ru/post/1763324/


All Articles