objective-c - cell.image 已弃用

标签 objective-c xcode uitableview deprecated

我想在 UITableView 的每一行中添加图片。

当我使用 cell.image = [UIImage imgNamed:@"xxx.png"]; 它跳出一条警告说 "image is deprecated"

虽然可行,但是否有任何替代方案不会产生警告?

最佳答案

是的,按照文档中的描述使用cell.imageView.image:

image

The image to use as content for the cell. (Deprecated in iOS 3.0. Instead use the imageView property to get UIImageView object and then get or set the encapsulated image.)

关于objective-c - cell.image 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8446124/

相关文章:

ios appearanceWhenContainedIn 只工作一次

iphone - 如何让UISlider的 "track"不可见?

ios - 如果未选择收件人,则显示警报 iOS

iphone - Objective-C 中不常用的符号

ios - UITableViewCell 中的 UIButton 在 iOS 5x 中没有响应但在 iOS 6 中响应

swift - 表节标题 : multi-line/word wrapping

objective-c - 为什么我们总是分配 Objective-C 原语?

ios - 如何以编程方式截取 iPad 主屏幕的屏幕截图?

ios - 面临自动调整大小问题

c++ - 同一段代码,可以在xcode中编译,也可以在terminal中用g++、clang++编译,不能用gcc或clang编译。为什么?