2012-03-26 95 views
0

我有2个视图。 A按钮和在视图1.在图2中的的UIImageView我有类别的列表表视图,我已成立使用用于每个类别的图像:现在如何从其他视图控制器获取图像

cell.imageView.image 

如果我选择一排,我应该看到一个视图1中该行的放大图像。我怎样才能做到这一点?

回答

0

使用委托方法。在第二个视图中选择一行后,传递UIImage对象或图像名称并将其设置为第一个视图中的图像视图。

有关委托方法的更多信息,请参阅以下链接。现在propertise

UIImage* currentImage; 

和合成对象:

The Basics of Protocols and Delegates

Using Protocols and Delegates to pass data between views

+0

我使用的协议...它适用于字符串,但它不适用于图像。 – Sekhar 2012-03-26 12:27:36

+0

你可以显示你的代码吗? – Ilanchezhian 2012-03-26 12:48:26

0

您可以使用应用程序委托的对象。

现在,当你在视图2和所选单元格,分配的UIImage到的appDelegate的对象:

appDelegate.currentImage = img;  // Hope you have an array which contains the images 
            // which are displayed in the UITableViewCell 

然后当视图2被驳回,调用视图1和在该通知方法的通知,分配该图像到View1的UIImageView对象:

imageview.image = appDelegate.currentImage; 
相关问题