更改 UIImage 中显示的图像 Swift
Changing image displayed in UIImage Swift
我的图像存在于 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]
}
我的图像存在于 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]
}