4

我正在使用本地 html 文件使用 UIWebview 加载带有图像的内容。我已在 Image.xcassests 中添加了所有图像。我们如何在本地 html 页面中链接 Image.xcassests 中的图像以显示

.menu {
    background: url("menu") no-repeat center center;
    background-size: 100% 100%;
    height: 16px;
    width: 26px;
} Menu is the name of the image assest i wish to use

I tried the following codes , images are not showing up

    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"welcome" ofType:@"html"];
    NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
   [htmlWebView loadHTMLString:htmlString baseURL:[[NSBundle mainBundle] bundleURL]];

Also 
   NSURL *url = [[NSBundle mainBundle] URLForResource:@"welcome" withExtension:@"html"];
   NSURLRequest* request = [NSURLRequest requestWithURL:url];
   [ htmlWebView loadRequest:request];
4

0 回答 0