首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将PHAsset转换为PHLivePhoto

如何将PHAsset转换为PHLivePhoto
EN

Stack Overflow用户
提问于 2016-01-12 16:13:30
回答 2查看 1.7K关注 0票数 0

我有PHAsset,我想要PHLivePhoto

PHAssetPHLivePhoto的资产。

我知道这个函数。

代码语言:javascript
复制
/// Requests a Live Photo from the given resource URLs. The result handler will be called multiple times to deliver new PHLivePhoto instances with increasingly more content. If a placeholder image is provided, the result handler will first be invoked synchronously to deliver a live photo containing only the placeholder image. Subsequent invocations of the result handler will occur on the main queue.
//  The targetSize and contentMode parameters are used to resize the live photo content if needed. If targetSize is equal to CGRectZero, content will not be resized.
//  When using this method to provide content for a PHLivePhotoView, each live photo instance delivered via the result handler should be passed to -     [PHLivePhotoView setLivePhoto:].
+ (PHLivePhotoRequestID)requestLivePhotoWithResourceFileURLs:(NSArray<NSURL *> *)fileURLs placeholderImage:(UIImage *__nullable)image targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode resultHandler:(void(^)(PHLivePhoto *__nullable livePhoto, NSDictionary *info))resultHandler;

但我不知道该怎么用。

如何转换?

EN

回答 2

Stack Overflow用户

发布于 2016-01-14 19:51:55

您可以在PHImageManager中使用此方法

代码语言:javascript
复制
- (PHImageRequestID)requestLivePhotoForAsset:(PHAsset *)asset targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode options:(PHLivePhotoRequestOptions *)options resultHandler:(void (^)(PHLivePhoto *livePhoto, NSDictionary *info))resultHandler

在resultHandler中,您可以获得可以在PHLivePhotoView中显示的PHLivePhoto。

示例:

代码语言:javascript
复制
[[PHImageManager defaultManager] requestLivePhotoForAsset:asset targetSize:self.contentView.frame.size contentMode:PHImageContentModeDefault options:nil resultHandler:^(PHLivePhoto * _Nullable livePhoto, NSDictionary * _Nullable info) { self.contentView.livePhoto = livePhoto  }];
票数 0
EN

Stack Overflow用户

发布于 2017-08-01 21:15:15

代码语言:javascript
复制
[asset requestContentEditingInputWithOptions:nil completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
PHLivePhoto *livePhoto = [contentEditingInput.livePhoto];
}];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34738493

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档