2013-10-17 51 views
0

我只是想知道是否可以從網站上拉取id「album_cover」。我需要將它加載到UIImageView。我還應該提到,代碼中的鏈接並不總是相同的,並且當歌曲改變時(Link to what website i'm referring to)會改變,這就是爲什麼我不能只接受URL並完成。iOS - 在網站上的javascript中將圖片加載到UIImageView中的網址

我想我可能能夠使用我的stringByEvaluatingJavaScriptFromString:@"document.getElementById('album_cover').textContent;"代碼,但我不知道如何將它裝入的UIImageView

下面是從網站上的圖像數據:

<div id="album_cover"> 
<img height="160px" width="160px" id="imgcover" src="http://api.cloudrad.io:8000/art/18a4c00346bccf046900f578b36bd2a5.png?nocache=2" alt="Loading..."> 
</div> 

謝謝!

回答

1

總之,你可能想:

  1. 解析元素字符串來獲取URL字符串
  2. 使用[NSData dataWithContentsOfURL:]得到的圖像數據
  3. 使用[UIImage imageWithData:]創建UIImage對象
  4. 請將您的UIImageViewimage物業與您的新形象聯繫起來
+0

我將如何解析圖像? –

相關問題