pushViewController中的方法是didFinishPickingMediaWithInfo

时间:2013-10-08 08:47:55

标签: ios objective-c uinavigationcontroller uiimagepickercontroller

当我使用pushViewController时,我会看到一个带导航按钮的空白视图 - Saved photos,我不知道为什么。 我想在选择图片后转到ReportViewController

这是我的代码,似乎没问题。什么可能出错?

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

//Geting the image from the camera
image = [info objectForKey:UIImagePickerControllerOriginalImage];

ReportViewController *imageSelectionVC = [[ReportViewController alloc] init];
[imageSelectionVC.imageReport setImage:image];

    [picker pushViewController:imageSelectionVC animated:YES];
}

1 个答案:

答案 0 :(得分:0)

正如评论所说,你必须解雇选择器并将新控制器推送到你的动画控制器(假设你有一个)

这是正确的代码:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];

    [picker dismissViewControllerAnimated:YES completion:^{
        ReportViewController *imageSelectionVC = [[ReportViewController alloc] init];
        [imageSelectionVC.imageReport setImage:image];

        [self.navigationController pushViewController:imageSelectionVC animated:YES];
    }];
}