ios - UIImagePicker URL 转换为 attributeOfItemAtPath iOS

标签 ios nsurl nsfilemanager

我一直在尝试找出如何将“UIImagePickerControllerReferenceURL”转换为可用于调用 NSFileManager 类的“attributesOfItemAtPath”方法的路径。

我尝试了[NSURL路径],但它没有将其转换为NSFileManager可以理解的目录路径...

是否有某种方法可以做到这一点,或者可能有另一种方法来获取使用 UIImagePicker 选取的文件的实际路径?

最佳答案

您得到的是 Assets 库 URL。您可以使用它来获取 asset您可以使用它来收集相关信息的对象。

ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
[library assetForURL:theAssetURL
         resultBlock:^(ALAsset * asset) {
                /* Use the "asset" object to get the details */
            }
        failureBlock:^(NSError * error) {
                /* Error retrieving the asset */
                NSLog(@"%@", [error localizedDescription]);
            }];

您可以查看 valueForKey:defaultRepresentation 方法。

关于ios - UIImagePicker URL 转换为 attributeOfItemAtPath iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6679305/

相关文章:

iphone - 将文件下载到 iPhone 中的文件夹

ios - AppStore 拒绝 : use of private calls refers to my own methods

iphone - EDT 到 GMT 转换

ios - 来自 UI 控件的奇怪 Bool 类型

ios - 是什么导致此代码中的 "invalid CFStringRef"?

cocoa - 通过网络复制文件夹

ios - 正确使用 NSFileHandle

ios - 逐步加载数据

ios - 比较空的 NSURL

ios - 在 UIImageView 中加载图像并调整容器的大小 - swift