gpt4 book ai didi

ios - PHAsset图像是否在所有iPhone上都具有全局唯一性?

转载 作者:行者123 更新时间:2023-12-01 19:52:36 24 4
gpt4 key购买 nike

使用Photo框架获取图像时,我从PHAsset对象获取画廊的所有图像。我的问题是,PHAsset中的图像是全局唯一的还是特定于设备的。我可以在不同的iPhone上使用相同的PHAsset图像吗?我不想将UIImage转换为NSData并将其再次从NSData转换为UIImage。

PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];

//set up fetch options, mediaType is image.
PHFetchOptions *options = [[PHFetchOptions alloc] init];
options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
options.predicate = [NSPredicate predicateWithFormat:@"mediaType = %d",PHAssetMediaTypeImage];

for (NSInteger i =0; i < smartAlbums.count; i++) {
PHAssetCollection *assetCollection = smartAlbums[i];
PHFetchResult *assetsFetchResult = [PHAsset fetchAssetsInAssetCollection:assetCollection options:options];

NSLog(@"sub album title is %@, count is %ld", assetCollection.localizedTitle, (unsigned long)assetsFetchResult.count);
if (assetsFetchResult.count > 0 && ![assetCollection.localizedTitle isEqualToString: @"Recently Deleted"]) {

for (PHAsset *asset in assetsFetchResult) {
PHImageRequestOptions *option = [PHImageRequestOptions new];
option.synchronous = YES;

[[PHImageManager defaultManager] requestImageForAsset:asset targetSize:CGSizeMake(self.view.frame.size.width, self.view.frame.size.height-100) contentMode:PHImageContentModeAspectFit options:option resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
[mutArrAsset addObject:asset];

[self.imagesURLArray addObject:result];
}];

NSLog(@"asset are %@", asset);
}}}

最佳答案

PHAsset表示指向用户照片库中图像的指针。人们在手机上具有不同的图像,因此将指针传递给其他手机没有任何意义。因此,PHAsset的ID称为localIdentifier

如果要将图像从一台设备传输到另一台设备,则必须将其作为NSData传输。

关于ios - PHAsset图像是否在所有iPhone上都具有全局唯一性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44923976/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com