开发者

take images from a cell , into next view controller

开发者 https://www.devze.com 2022-12-26 11:23 出处:网络
i asked this question yesterday but it doesnt seem to have asked properly so im trying again in my app im parsing in an xml file , in that file there is a path for an image to download

i asked this question yesterday but it doesnt seem to have asked properly so im trying again

in my app im parsing in an xml file , in that file there is a path for an image to download

an in my tableview controler i have this to download the image and display it in the cell

NSURL *url = [NSURL URLWithString:aStory.picture];
 NSData *data = [NSData dataWithContentsOfURL:url];
 UIImage *img = [[UIImage alloc] initWithData:data];

im then pushing another view controller on the top and displaying some text in a text view , but i also want to take the image开发者_如何学运维 from the cell selected and put that in there too , but everything i try does not work.

any ideas on how i can do this

Thanks in advance Richard


You need to create a property in the target ViewController to hold the image

UIImage *myDownloadedImage;
}

@property (nonatomic, assign) UIImage *myDownloadedImage;

and then when you are about to push you add the image to the controller

myNextViewController.myDownloadedImage = img;
[self.navigationController pushViewController:myNextViewController animated:YES];

Now you have access to the image to do as you wish

0

精彩评论

暂无评论...
验证码 换一张
取 消