我想使用assetURL 获取PHAsset。我使用了以下代码:
NSURL *assetURL=[NSURL URLWithString:file.filePath];
PHFetchResult *fetchResult=[PHAsset fetchAssetsWithALAssetURLs:@[assetURL] options:nil];
PHAsset *asset= [fetchResult firstObject];
file.filePath 具有我从中获取的资产 url
[[PHImageManager defaultManager]
requestImageDataForAsset:asset
options:imageRequestOptions
resultHandler:^(NSData *imageData, NSString *dataUTI,
UIImageOrientation orientation,
NSDictionary *info)
{[uploadingFile setValue:[NSString stringWithFormat:@"%@",[info valueForKey:@"PHImageFileURLKey"]] forKey:@"filePath"];}
但我总是得到fetchResult
as的价值nil
。有人能告诉我我哪里出错了吗?是因为我传递了错误的 URL 类型吗?