我有一个按钮,它将以编程方式为他们从照片库中选择的每张照片创建一个带有图像的 UIImageView。它将照片放在视图上,您可以四处移动它等等。
当用户按住图像时,它会在 iPad 上弹出一个 UIPopOverController。从那里,用户单击一个按钮来编辑当前被触摸的图像。
我遇到的问题是我无法重新访问该 UIImageView.image 以将图像更改为刚刚编辑的完成图像。
这是一些代码示例。
// 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];
}
}
然后,我将使用 popupEditor 视图上的按钮弹出我的 editorController:
- (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];
}
}
然后在用户完成照片编辑后调用它:
- (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];
}
我不知道如何重新访问 UIImageView.image。我已经尝试过标签和 nsuserdefaults 但无济于事!
任何帮助将不胜感激!!谢谢!