【发布时间】:2018-03-10 22:34:39
【问题描述】:
我正在遍历 URL 数组,以便在我的表格视图单元格中显示图像。由于某种原因,在选择单元格之前不会显示图像。一次只显示一个图像,因此当我在一个单元格上选择显示图像时,一旦我选择另一个单元格,它将再次消失。我不确定是什么问题,因为文本显示没有问题:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "resultCell", for: indexPath) as! ResultsTableViewCell
var place = [String]()
var img = [String]()
if imageUrls.count == venueIds.count {
for (key,value) in restaurantInfo {
place.append(value[0])
img.append(value[1])
}
let search = img[indexPath.row]
Alamofire.request(search).responseImage { response in
if let image = response.value {
cell.imageSelection.image = image
}
else{
print(response.result.error!)
}
}
cell.newLabel.text = place[indexPath.row]
}
return cell
}
【问题讨论】:
标签: ios swift uitableview uiimage