OGeek|极客世界-中国程序员成长平台

标题: ios - UIImagePicker URL 转换为 attributesOfItemAtPath iOS [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 08:23
标题: ios - UIImagePicker URL 转换为 attributesOfItemAtPath iOS

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

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

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



Best Answer-推荐答案


您得到的是一个 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 转换为 attributesOfItemAtPath iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6679305/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4