0
我在自定義UITableViewCell中顯示UIImageView,僅用於那些在Firebase響應中設置了圖像URL的單元。代碼如下:UITableViewCell中的UIImageView不顯示條件
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cellIdentfier = "ArticleTableViewCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentfier, forIndexPath: indexPath) as!ArticleTableViewCell
//Configure the cell
// Added by ankit khanna for UIImageView change
let imageURL = imageArray[indexPath.row]
print ("Final Image URL: [\(imageURL)]")
if (imageURL == "NIL") {
cell.articalImageView.hidden = true
}
let fileUrl = NSURL(string: imageURL as String)
print ("File URL : [\(fileUrl!)]")
cell.articalImageView.hnk_setImageFromURL(fileUrl!)
// End
}
問題是,如果我刪除if條件if (imageURL == "NIL")
圖像顯示正常,但後來當我向後滾動的圖像開始顯示它不應該出現。
圖像陣列:var imageArray = [String]()
下面是我在哪裏追加數組
if (snapshot.value.objectForKey("image") != nil)
{
let url = snapshot.value.objectForKey("image")!
let f_url = String(url)
// print ("image1 URL : \(f_url)")
self.imageArray.append(f_url)
}
else if (snapshot.value.objectForKey("image") == nil)
{
self.imageArray.append("NIL")
}
我怎麼想禁用的UIImageView的地方是空的響應代碼。