第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在UIWebView中使用HTML和本地圖像

在UIWebView中使用HTML和本地圖像

iOS
回首憶惘然 2019-07-26 15:14:41
在UIWebView中使用HTML和本地圖像我有一個UIWebView在我的應(yīng)用程序,我想用來顯示一個圖像,將鏈接到另一個網(wǎng)址。我在用<img src="image.jpg" /> to load the image.問題是圖像沒有加載。即使它作為資源添加到我的項(xiàng)目中并被復(fù)制到包中,也是找不到的。我嘗試使用NSBundle獲取圖像的完整路徑,并且使用它,但它仍然沒有顯示在Web視圖中。有什么想法嗎?
查看完整描述

3 回答

?
人到中年有點(diǎn)甜

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超7個贊

用這個:

[webView loadHTMLString:htmlString baseURL:[[NSBundle mainBundle] bundleURL]];


查看完整回答
反對 回復(fù) 2019-07-27
?
30秒到達(dá)戰(zhàn)場

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超6個贊

我也遇到了這個問題。在我的例子中,我處理的是一些沒有本地化的圖像,還有一些是多種語言的圖像?;綰RL沒有為我獲取本地化文件夾中的圖像。我通過以下操作解決了這個問題:

// make sure you have the image name and extension (for demo purposes, I'm using "myImage" and "png" for the file "myImage.png", which may or may not be localized)NSString *imageFileName = @"myImage";NSString *imageFileExtension = @"png";// load the path of the image in the main bundle (this gets the full local path to the image you need, including if it is localized and if you have a @2x version)NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageFileName ofType:imageFileExtension];// generate the html tag for the image (don't forget to use file:// for local paths)NSString *imgHTMLTag = [NSString stringWithFormat:@"<img src=\"file://%@\" />", imagePath];

然后,在加載內(nèi)容時(shí),在UIWebView HTML代碼中使用imgHTMLTag。

我希望這對任何遇到同樣問題的人都有幫助。




查看完整回答
反對 回復(fù) 2019-07-27
  • 3 回答
  • 0 關(guān)注
  • 378 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號