【问题标题】:does not respond to selector image:didFinishSavingWithError:contextInfo:不响应选择器 image:didFinishSavingWithError:contextInfo:
【发布时间】:2013-01-29 06:00:14
【问题描述】:

感谢您的阅读,这是我的问题。 我正在尝试保存一张图片(我使用 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”有关。

【问题讨论】:

    标签: ios cocoa-touch uiimagepickercontroller


    【解决方案1】:

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

     -(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");
     }
    }
    

    【讨论】:

      【解决方案2】:

      您的班级(自己)没有响应选择器 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");
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多