我正在尝试使用按钮更改第二个viewController 上的图像,但我不知道怎么做?我是否需要做一些事情或者只是为了准备segue而传递它:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"the_segue"]){
imageView.image=@"photo.jpg"
}
}
谢谢!
答案 0 :(得分:0)
试试这个
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"the_segue"]){
secondViewController *VC2 = (secondViewController *)segue.destinationViewController
VC2.imageView.image=@"photo.jpg"
}
}
在SecondViewController中看起来像
@interface secondViewController : UIViewController
@property(strong,readwrite) UIImageView *imageView;
@end