【问题标题】:Incompatible pointer types sending 'UIImage *__strong' to parameter of type 'NSString upload to dropbox不兼容的指针类型将“UIImage *__strong”发送到“NSString 上传到保管箱”类型的参数
【发布时间】:2012-12-07 06:43:17
【问题描述】:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
[self dismissViewControllerAnimated:YES completion:nil];
NSURL *kittenFileURL = [[NSBundle mainBundle] URLForResource:img withExtension:nil];
}

这是我的代码。警告我得到它不兼容的指针类型将'UIImage *__strong'发送到'NSString *'类型的参数当我去收集要上传到保管箱的用户图像的url时,它会使应用程序崩溃。有什么想法吗?

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:

    URLForResource: 在传递图像时需要一个字符串。这就是错误。你需要在那里传递一个字符串。

    [[NSBundle mainBundle] URLForResource:stringPath withExtension:nil];
    

    不确定您打算如何处理,但 URLForResource: 参数需要路径或文件名,而不是 UIImage。更多详情check the apple documentation here.

    只是猜测,您想获取该图片的媒体网址吗?在这种情况下,您需要这样做,

    NSURL *kittenFileURL = [editInfo valueForKey:UIImagePickerControllerMediaURL];
    

    available keys are listed here.。您可以使用参考网址,[editInfo valueForKey:UIImagePickerControllerReferenceURL]

    附带说明,imagePickerController:didFinishPickingImage:editingInfo: 已弃用,您应该使用 imagePickerController:didFinishPickingMediaWithInfo:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多