ios - 更改在 UIImage Swift 中显示的图像

标签 ios swift uiimage

我的图像存在于 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/

相关文章:

ios - 音频队列 : Can't read raw data in AudioFileReadPackets

html - 如何允许缩放 UIWebView(什么都试过了)

ios - 如何使用警报 View 刷新 uitableivew?

swift 3 : Method expecting variadic String parameter can only receive single String argument

objective-c - 如何降低 iPhone objective-c 中的图像质量/尺寸?

cocos2d-iphone - 如何将 CCSprite 图像转换为 UIImage?

ios - 切换 View 时 UIScrollview 跳出屏幕

ios - 仅从 Parse 中获取 PFObject 的一些键以节省数据量 - iOS

ios - defer 语句和 return 之前的语句有什么区别?

ios - 上传图片到 Firebase