我的图像存在于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'
}
我该怎么办?
答案 0 :(得分:2)
类型转换是必须的
if let nimage:UIImageView = cell.viewWithTag(111) as! UIImageView{ // 111 is a UIImageView
nimage.image = imageCache[urlString]
}