简体   繁体   English

如何以编程方式更改显示在单元格中的UIImageView中的图像?

[英]How can I change the image displayed in an UIImageView in a cell programmatically?

Hi Guys i was wondering how to set the image of an UIimageView that is in a cell. 大家好,我想知道如何设置单元格中的UIimageView的图像。 I'm rather new to coding so please fully explain if u can. 我是编码的新手,所以请充分说明您是否可以。 I currently have this: 我目前有这个:

cell.image.image = [tempObject objectForKey:@"CafeImage"];

But the app crashes with this everytime: 但是应用每次都会崩溃:

-[PFFile imageAsset]: unrecognized selector sent to instance 0x7a96cd80 2015-02-22 15:06:19.616 Cafe[12830:140389] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFFile imageAsset]: unrecognized selector sent to instance 0x7a96cd80'

它应该是cell.imageView.image = [tempObject objectForKey:@“ CafeImage”];

first - If you are using a standard cell, you should set 首先-如果您使用的是标准单元格,则应设置

cell.imageView.image = "UIImage object";

second - Data in [tempObject objectForKey:@"CafeImage"] must be kind of UIImage class, or if it's NSString -> use [UIImage imageName:@"for example - objectForKey"]; 第二-[tempObject objectForKey:@“ CafeImage”]中的数据必须是UIImage类,或者如果它是NSString->使用[UIImage imageName:@“例如-objectForKey”];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以编程方式更改 UIImageView 中显示的图像? - How can I change the image displayed in a UIImageView programmatically? 如何以编程方式更改UIImageView的高度? - How can I change the height of an UIImageView programmatically? 如何以编程方式更改UIButton内的UIImageView的图像? - How to change image of UIImageView that is inside a UIButton programmatically? 如何以编程方式更改uiimageview图像 - how to change uiimageview image's programmatically 如何在单元格的按钮单击中更改表格单元格中的UIImageView图像? - How to Change an UIImageView Image in a Table cell, on a button click from the cell? 如何在 NativeScript 中以编程方式创建 UIImageView? - How can I create a UIImageView programmatically in NativeScript? 如何在Swift中使用UISlider在UIImageView中以编程方式更改指定的图像大小 - How to change specified image size in UIImageView with UISlider in Swift programmatically 使用变量更改UIImageView中显示的图像的名称 - Using a variable to change the name of an image displayed in an UIImageView 如何将2个UIImageView中的2个图像合并为1个图像 - How can I merge 2 image in 2 UIImageView into 1 image 以编程方式按下UIButton时在UIImageView中更改图像 - Change image in UIImageView when UIButton is pressed programmatically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM