将 UIImage 从一个视图控制器传递到 UITableViewCell [英] Passing a UIImage from one view controller to a UITableViewCell

查看:36
本文介绍了将 UIImage 从一个视图控制器传递到 UITableViewCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 UITable 来显示图像(就像 instagram 中的提要)我将图像保存在视图控制器中我正在拍照,但我需要一种方法将我创建的 UIImage 传递给 UITableViewCell.实现这一目标的最佳方法是什么.

I am using a UITable to show images (Like a feed in instagram) I have the image saved in the viewcontroller I am taking the picture, but I need a way to pass the UIImage i have created to the UITableViewCell. What would be the best way to accomplish this.

推荐答案

你需要继承 UITableViewCell 并给它一个像

You need to subclass UITableViewCell and give it a public property like

@property (nonatomic, strong) UIImage *thumbnailImage;

然后在您的 uitableviewcells 实现文件中创建并添加您想要的 UIImageView.

then in your uitableviewcells implementation file create and add a UIImageView however you want.

- (void)setThumbnailImage:(UIImage *)thumbnailImage
{
   _thumbnailImage = thumbnailImage;
   self.imageView.image = _thumbnailImage;
}

在你的 cellForRowAtIndexPath 方法中,做一些类似的事情

in your cellForRowAtIndexPath method, do something like

cell.thumbnailImage = [UIImage imageNamed:"YourImage.png"];

这只是实现此目的的众多方法之一.

This is just one of many ways to do this.

这篇关于将 UIImage 从一个视图控制器传递到 UITableViewCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆