我的图像存在于 tableView Cell 中,所以我使用以下代码对其进行更改:(如果下面有任何混淆,我正在从缓存中更新图像)
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if let nimage = cell.viewWithTag(111){ // 111 is a UIImageView
nimage.image = imageCache[urlString]
// above error - nimage has no member named image
nimage = imageCache[urlString]
// above error - cannot assign to 'let' value 'UIImage'
}
我该怎么办?
最佳答案
这里必须进行类型转换
if let nimage:UIImageView = cell.viewWithTag(111) as! UIImageView{ // 111 is a UIImageView
nimage.image = imageCache[urlString]
}
关于ios - 更改在 UIImage Swift 中显示的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31200556/