I have a button that will programmatically create a UIImageView with an image for each photo that they choose from their Photo Library. It puts the photo on the View and you can move it around and what not.
When the user holds down on the image it brings up a UIPopOverController on the iPad. From there the user clicks on a button to edit the image that is currently being touched.
The problem I have is that I cannot re-access that UIImageView.image to change the image to the finished image that was just edited.
Here is some code example.
// This figures out what imageView was tapped
- (void)handleEditTapped:(UITapGestureRecognizer *)recognizer {
editImage = (UIImageView*)recognizer.view;
if(UIGestureRecognizerStateBegan == recognizer.state) {
// Called on start of gesture, do work son!
popoverEditor = [[UIPopoverController alloc] initWithContentViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"popupEditor"]];
[popoverEditor presentPopoverFromRect:editImage.bounds inView:editImage permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
I then will popup my editorController with a button located on the popupEditor View:
- (IBAction)effectsEditorButton:(id)sender {
// This part I've been fooling around with to save the image and re-load it to try and get it to work but it loads successfully to the editor but will not save back to uiimageview.image
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *imageData = [defaults dataForKey:@"image"];
UIImage *loadedImage = [UIImage imageWithData:imageData];
myEditorController *editorController = [[myEditorController alloc] initWithImage:loadedImage];
[editorController setDelegate:self];
popoverEditor = [[UIPopoverController alloc] initWithContentViewController:editorController];
[popoverEditor presentPopoverFromRect:self.effectsButtonImage.bounds inView:self.effectsButtonImage permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
And then this gets called after the user has finished editing the photo:
- (void)photoEditor:(myEditorController *)editor finishedWithImage:(UIImage *)finishedImage
{
// NSLog(@"TAG: %i",editImage.tag); Tried tags but wouldn't hold the .tag value to re reference it. Would always result in 0 after I set the tag to 10 on handleEditTapped
editImage.image = finishedImage;
[self.popoverEditor dismissPopoverAnimated:YES];
}
I cannot figure out how to re-access the UIImageView.image. I’ve tried tags and nsuserdefaults but to no avail!
Any help would be greatly appreciated!! Thank you!
This question is highly about application logic and depends greatly on how you’ve designed your objects, not so much on the framework, iOS, or objc. In that regard, a few suggestions about how you might tweak your application design to address this problem. There’s not quite enough info to give a complete answer, but hopefully this helps.