【问题标题】:UIImagePicker URL convert for attributesOfItemAtPath iOSUIImagePicker URL 转换为 attributesOfItemAtPath iOS
【发布时间】:2011-10-04 11:47:43
【问题描述】:

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

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

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

【问题讨论】:

  • 你想获取什么信息?
  • 主要是FileSize、FileName、DateCreated等

标签: ios nsurl nsfilemanager


【解决方案1】:

您得到的是一个资产库 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 方法。

【讨论】:

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