使用按钮在单独的 ViewController 中更改 UIimageView 中的图像 [英] Using a Button to change an Image in a UIimageView in a separate ViewController
问题描述
我有几个不同的按钮,它们都模态地连接到另一个包含多个 UIimage 视图的 ViewController.我想要做的是为每个按钮创建一个 IBAction,将图像设置为另一个 ViewController 中的 UIimageViews.(我的 UIimageViews 是 @property(nonatomic,retina),我尝试了多种代码,如setImage"和许多其他代码,但没有成功)我想知道这是否可以通过使用标签来完成?
I have several different buttons, which are all segued modally to another ViewController that contains several UIimage views. What I'm trying to do is to create an IBAction for each button that will set images to the UIimageViews in the other ViewController. (my UIimageViews are @property(nonatomic, retina) and I have tried multiple codes like "setImage" and many others with no success) I wass wondering if this could be done by using tags?
谢谢!!!
推荐答案
Use Delegates 委托.在按钮上单击调用委托上的选择器.在选择器中设置图像.
Use Delegates delegate. On button click invoke the selector on the delegate. In the selector set the image.
这篇关于使用按钮在单独的 ViewController 中更改 UIimageView 中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!