PHAsset为空,但本地标识符有效

问题描述 投票:0回答:1

我正在尝试从本地标识符加载资产。本地标识符似乎是正确的,但是资产为空,我不知道为什么。我的应用程序的另一部分也有类似的代码,可以正常工作。

Queue *queue = [NSEntityDescription insertNewObjectForEntityForName:@"Queue" inManagedObjectContext:self.context];

for (int reyrt = 0; reyrt < self.storeGIF.count; reyrt++) {
    queue.queuetextimagePath = [self.storeGIF objectAtIndex:reyrt];

}


__block float fileSize;
NSArray *identifiers = @[queue.queuetextimagePath];
PHFetchResult *assetsFetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:identifiers options:nil];
PHAsset *asset  = [assetsFetchResult firstObject];

NSLog (@"identifiers: %@", identifiers);
NSLog (@"assetsFetchResult: %@", assetsFetchResult);
NSLog (@"asset: %@", asset);
    if (!asset) {
        NSLog(@"can't retrieve PHAsset from localIdentifier:%@",identifiers);
    }

这是使用上述代码时的NSLog文件结果。

019-07-19 09:26:36.366739-0400 myApp[1440:328144] identifiers: (
"857AC3DA-C047-4D88-911B-C5FE227E2B96/L0/001"
)

2019-07-19 09:26:36.366945-0400 myApp[1440:328144] assetsFetchResult PHFetchResult: 0x281129900 count=0

2019-07-19 09:26:36.366982-0400 myApp[1440:328144] asset: (null)

2019-07-19 09:26:36.367061-0400 myApp[1440:328144] can't retrieve PHAsset from localIdentifier:(
"857AC3DA-C047-4D88-911B-C5FE227E2B96/L0/001"
)
ios objective-c phasset photosframework
1个回答
0
投票

问题是,在请求对象之前,应先删除/L0/001部分。我不明白为什么uuid字符串包含这些后缀,但是如果您将其删除并仅使用普通的UUID部分,它会起作用。

© www.soinside.com 2019 - 2024. All rights reserved.