我正在使用库GKClass,它基本上是一个自定义的imagePickerController类。 我无法传递数据 - 图像到下一个控件视图,而它正在使用简单的imagePickerController它现在不能正常工作,ViewController无法获取数据。
-(void)imagePicker:(GKImagePicker *)imagePicker pickedImage:(UIImage *)image
{
VCImageEditingViewController *ieVC = [[VCImageEditingViewController alloc]init];
ieVC.selectedIMG = image;
[self.imagePicker.imagePickerController dismissViewControllerAnimated:NO completion:nil];
[self performSegueWithIdentifier:@"imgrdy" sender:self];
}
和VCImageEditingViewController.m:
- (void)viewDidLoad
{
[super viewDidLoad];
if (self.selectedIMG == nil) {
NSLog(@"no img set");
}
self.imageDisplayed.image = self.selectedIMG;
}
我也在viewDidAppear中尝试了它,但仍然没有,“选择器”在iv尝试后正在运行:
-(void)imagePicker:(GKImagePicker *)imagePicker pickedImage:(UIImage *)image
{
[self.imagePicker.imagePickerController dismissViewControllerAnimated:NO completion:nil];
self.lastImageView.image = image;
}
它显示当前视图控制器中的图像。
我的猜测是在修改图像之前显示目标viewController。
想要一些帮助。谢谢。
答案 0 :(得分:2)
试试这个
-(void)imagePicker:(GKImagePicker *)imagePicker pickedImage:(UIImage *)image
{
[self.imagePicker.imagePickerController dismissViewControllerAnimated:NO completion:nil];
//pass image with peroformsegue
[self performSegueWithIdentifier:@"imgrdy" sender: image];
}
// In prepare segue method assign image to destination view controller
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"imgrdy"])
{
VCImageEditingViewController *ieVC=segue.destinationViewController;
ieVC.selectedIMG =(UIImage *) sender;
}
}