为什么我无法保存和预览照片

时间:2013-08-13 03:17:31

标签: ios

如果我评论保存照片的代码,我可以预览照片,如果我评论预览照片的代码,我可以将照片保存到相机胶卷

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
    [self.library saveImage:image toAlbum:@"Testing" withCompletionBlock:^(NSError *error) {
    if (error!=nil) {
        NSLog(@"Big error: %@", [error description]);
    }
}];
    [picker dismissModalViewControllerAnimated:NO];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissModalViewControllerAnimated:YES];
    photoPreview.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}

1 个答案:

答案 0 :(得分:0)

好吧,如果你正在评论其中一个当然不会起作用。你必须合并这些方法。

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

    [self.library saveImage:image toAlbum:@"Testing" withCompletionBlock:^(NSError *error) {
    if (error!=nil) {
        NSLog(@"Big error: %@", [error description]);
    }
}];
    [picker dismissModalViewControllerAnimated:NO];
}