I create an app with custom camera picker, and i try to pass the overlay image from a class to other class, below more infos about my code:
Using Storyboard:
UICollectionView
load a .plist
with images from web then using Segue Identify
to pass the information to another View.
In My second view i see my chose image, share buttons and Camera button, if i tap camera button loading mu Custom camera view in a separate .xib
, her i want to pass my first chose image to a UIImageView in a .xib
Here My code:
The process of 3 controllers is:
First controller from a UITableView
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([@"goToShare" isEqualToString:segue.identifier]) {
NSIndexPath *index = [self.tableView indexPathForCell:sender];
[[segue destinationViewController] setImgSelected:(self.loadImage)[index.row]];
}
}
Here set my image in to NSMutableDictionary *imgSelected;
In my second controller i get the information in to:
- (void)viewDidLoad {
NSString *url = (self.imgSelected)[@"image"];
NSData *data = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:url]];
imageViewPick.image = [[UIImage alloc] initWithData:data];
[super viewDidLoad];
}
Now i want to pass from second controller imageViewPick.image
the same image in the third controller in to my imageOverlay.image
When tap on Camera Button and load cover vertical my .xib
:
- (IBAction)getPhoto:(id) sender {
CustomCameraViewController *camController = [[CustomCameraView alloc] initWithNibName:@"CustomCameraView" bundle:nil];
camController.delegate = self;
[self presentViewController:camController animated:YES completion:^{
}];
}
I try to get imageViewPick.image
with:
MyFirstView *imgDelegate= (MyFirstView *)[[UIApplication sharedApplication] delegate];
self.imageOverLay.image = imgDelegate.imageViewPick.image;
But not working and the app crash.
Any idea how to pass the information from firstClass.m
to a secondClass.m
?