嘿,我有两个UIViewControllers
。在第一个,有一个UIButton
其中包含一个图像。当用户到达我的第二个ViewController
时,有许多按钮,其中包含不同的图像。所以,当用户按下我的VC2中的一个按钮时,它应该将自身的图像设置为我VC1上的UIButton。从另一个类访问IBOutlet
我已经加入实现了第一个VC: #import "ViewController1.h"
到@interface ViewController2()
的ViewController2.m
前
我怎么能这样做?例如:
VC2:
- (IBAction)seaButton:(id)sender {
//Access the IBOutlet from VC1 and set the image of the Button like:
UIImage * seaBtnImage = [UIImage imageNamed:@"Sea.png"];
[buttonOutlet setImage:seaBtnImage forState:UIControlStateNormal];
}
谢谢!
将店铺视为私人店铺。如果视图控制器具有相互传递的信息,则应该使用方法来配置它们,以便可以在另一个方法中调用该方法。 – matt 2014-08-31 17:23:12