简体   繁体   English

如何在iOS7中使用情节提要传递图像

[英]how to pass the image using storyboard in ios7

I cant able to pass the image from 1 view to another view in ios7. 我无法将图像从1个视图传递到ios7中的另一个视图。

in current view 在当前视图中

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showRecipeDetail"]) {
BehindContributors *destViewController = segue.destinationViewController;
[destViewController setImage:@"1.jpg"];
}

in destination view 在目标视图中

    self.image1.image=self.image;

did you try imageNamed method on ÙIImage 您是否在ÙIImage上尝试过imageNamed方法

like so; 像这样

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
   if ([segue.identifier isEqualToString:@"showRecipeDetail"]) {
      BehindContributors *destViewController = segue.destinationViewController;
   [destViewController setImage:[UIImage imageNamed:@"1.jpg"]];
}

What are you trying to pass image name(ie NSString object) or image itself(ie UIImage object). 您正在尝试传递图像名称(即NSString对象)或图像本身(即UIImage对象)。

If you are passing image name then use following 如果要传递图像名称,请使用以下命令

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"showRecipeDetail"]) {
        BehindContributors *destViewController = segue.destinationViewController;
        [destViewController setImageName:@"1.jpg"];
    }
}

Destination view should have property imageName of NSString type then use it as 目标视图应具有NSString类型的imageName属性,然后将其用作

self.imageView.image = [UIImage imageName:imageName];

If you are passing image then use following 如果要传递图像,请使用以下命令

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"showRecipeDetail"]) {
        BehindContributors *destViewController = segue.destinationViewController;
        [destViewController setImageData:[UIImage imageNamed:@"1.jpg"]];
    }
}

Destination view should have property imageData of UIImage type then use it as 目标视图应具有UIImage类型的imageData属性,然后将其用作

self.imageView.image = imageData;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM