Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何使用IBAction在另一个页面Xcode上显示图片?_Ios_Objective C - Fatal编程技术网

Ios 如何使用IBAction在另一个页面Xcode上显示图片?

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:@"

当我点击上一页上的按钮时,我希望我的图像出现在下一页上,这可能吗?我已经把故事板设置为点击按钮时按下…它进入页面,但我的图像没有显示

这是我的.h代码:

@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:知道答案吗?