不响应选择器图像:didFinishSavingWithError:contextInfo:

时间:2013-01-29 06:00:14

标签: ios cocoa-touch uiimagepickercontroller

感谢您的阅读,这是我的问题。 我试图保存图片(我使用UIImagePickerController方法拍摄)虽然我有一个错误。错误是“不响应选择器图像:didFinishSavingWithError:contextInfo:”

我在其他地方已经读过将实例方法更改为类方法(但我是菜鸟,不知道这意味着什么。)这是我的代码:D。

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



// Access the uncropped image from info dictionary
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

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

我被告知这与UIImageWriteToSavedPhotosAlbum方法中的“Self”有关。

2 个答案:

答案 0 :(得分:3)

使用此代码保存您选择的图片:

 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{
 UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
 UIImageWriteToSavedPhotosAlbum(image,self,  
                                   @selector(image:finishedSavingWithError:contextInfo:),
                                   nil);
}

并添加此功能。

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo: (void *)contextInfo
{
if (error != nil) 
 {
    NSLog(@"Image Can not be saved");
 } 
 else 
 {
    NSLog(@"Successfully saved Image");
 }
}

答案 1 :(得分:2)

您的类(self)不响应选择器 image:didFinishSavingWithError:contextInfo:。 您应该实现此选择器。 像这样的东西

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
    if (error != nil) {
        NSLog(@"Couldn't save image");
    } else {
        NSLog(@"Saved image");
    }
}