1

我正在使用库 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 中尝试过,但仍然没有,“选择器”自从我尝试过以来一直在工作:

-(void)imagePicker:(GKImagePicker *)imagePicker pickedImage:(UIImage *)image
{
    [self.imagePicker.imagePickerController dismissViewControllerAnimated:NO completion:nil];
    self.lastImageView.image = image;
}

它在当前视图控制器中显示图像。

我的猜测是目标 viewController 是在修改图像之前呈现的。

在这里需要一些帮助。谢谢你。

4

1 回答 1

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;
 } 
 }  
于 2013-10-18T10:48:12.390 回答