Ios 如何使用IBAction在另一个页面Xcode上显示图片?
当我点击上一页上的按钮时,我希望我的图像出现在下一页上,这可能吗?我已经把故事板设置为点击按钮时按下…它进入页面,但我的图像没有显示 这是我的.h代码:Ios 如何使用IBAction在另一个页面Xcode上显示图片?,ios,objective-c,Ios,Objective C,当我点击上一页上的按钮时,我希望我的图像出现在下一页上,这可能吗?我已经把故事板设置为点击按钮时按下…它进入页面,但我的图像没有显示 这是我的.h代码: @property (strong, nonatomic) IBOutlet UIImageView *Image1; - (IBAction)Button:(id)sender; 还有我的 - (IBAction)Button:(id)sender { UIImage *img = [UIImage imageNamed:@"
@property (strong, nonatomic) IBOutlet UIImageView *Image1;
- (IBAction)Button:(id)sender;
还有我的
- (IBAction)Button:(id)sender {
UIImage *img = [UIImage imageNamed:@"image.png"];
[_Image1 setImage:img];
}
我想这一定是因为它一旦打开新的一页,就忘记了这个动作,但我不确定,因为我好像还记得
任何帮助都会很好!!
谢谢为segue提供一个标识符(如ShowSecondScreen),用于连接两个
视图控制器
然后,从第一个viewController启动segue
[self performSegueWithIdentifier:@"ShowSecondScreen" sender:self];
在secondViewController
中创建strong
属性
要处理这个被解雇的segue,使用
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"ShowSecondScreen"]) {
SecondViewController *secondViewController = segue.destinationViewController;
secondViewController.passedImage = image;
}
}
按钮不可见意味着?很抱歉,我的意思是图像不显示!请用小写字母命名您的var,方法也是如此。你说的“页面”是什么意思?另一个视图控制器?如果是,我想,你必须看看如何通过分段传递数据。@user3255316:知道答案吗?