0

我想用 iPad 应用程序加载一个 html 文件,但是在 html 文件中有一个图像,并且该图像有一个触摸事件。当我使用 webview 加载 html 文件时,图像不会出现。这是为什么?

我正在使用代码:

UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
webView.backgroundColor = [UIColor lightGrayColor];
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"2line1" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURLURLWithString:@""]];
4

1 回答 1

0

试试这个方法,

  htmlString = [NSString stringWithFormat = @"<p><img src='https://yourpath/images/image.png'></p>";
     [yourwebview loadHTMLString:htmlString baseURL:nil];
于 2013-06-12T12:28:07.707 回答