2

我想要做的就是在警报显示图片已保存或未保存之后,选择器应该被解雇,但我无法找出如何。

我这样呈现图像控件:

[self presentModalViewController:imagePicker animated:YES];

我知道我需要关闭modalviewcontroller,因为我是为取消案例做的,但我不知道在哪里放置它,以便在图像保存后它存在。

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

        UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
    }

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
    UIAlertView *alert;

    // Unable to save the image  
    if (error)
        alert = [[UIAlertView alloc] initWithTitle:@"Error" 
                                           message:@"Unable to save image to Photo Album." 
                                          delegate:self cancelButtonTitle:@"Ok" 
                                 otherButtonTitles:nil];
    else // All is well
        alert = [[UIAlertView alloc] initWithTitle:@"Success" 
                                           message:@"Image saved to Photo Album." 
                                          delegate:self cancelButtonTitle:@"Ok" 
                                 otherButtonTitles:nil];
    [alert show];
}
4

2 回答 2

1

您必须在本地和 alertview 委托方法中创建 UIImagePickerController 的实例,只需将其关闭。

于 2012-04-12T11:04:03.810 回答
0

如果您使用过 peserntmodelviewcontrolleranimated: 那么使用dismissModalViewControllerAnimated:

于 2012-04-12T10:59:44.597 回答