为dismissModalViewControllerAnimated设置委托

时间:2013-02-13 02:06:17

标签: objective-c xcode delegates uiimagepickercontroller

我的应用程序中有一个UIImagePickerController,它使用didFinishPickingMediaWithInfo委托监视用户是否选择了图像。

-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

    if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
        UIImage *image = [info
                          objectForKey:UIImagePickerControllerOriginalImage];
    }
    [picker dismissModalViewControllerAnimated:YES];
}

当调用[picker dismissModalViewControllerAnimated:YES]时,它将关闭当前的UIImagePickerController视图并在显示UIImagePicker之前返回视图。我想设置一个委托,以便在调用dismissModalVewControllerAnimated时将所选图像发送回上一个视图。我怎么做?非常感谢!

1 个答案:

答案 0 :(得分:0)

创建选择器时应设置委托。控制器是否会回到创建选择器的控制器?如果是这样,它应该在那时将自己设置为委托。你应该使用dismissViewControllerAnimated:completion:而不是折旧的dismissModalViewController。