3

我有一个用 BASE64 编码的图像,我从服务器检索该图像,然后将其加载到 UIWebView 中:

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

图像加载正常,但是当图像大于我的 webviewer 时,用户无法像在所有其他 UIWebView 文档中一样通过捏 iPhone 来放大和缩小。

用户可以四处移动图片来查看整个图片,但是由于他们无法缩小,所以他们无法在 UIWebView 框架的大小中看到整个图片。

有没有人有这个问题的解决方案。谢谢。

4

1 回答 1

3

将此添加到您的 webview 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];
于 2010-09-05T15:22:40.700 回答