小编Eri*_*hao的帖子

如何在相册中保存自制的实时照片?

我尝试用JPG文件和MOV文件制作实时照片.就像这样:

   CGSize targetSize = CGSizeZero;
    PHImageContentMode contentMode = PHImageContentModeDefault;


    __weak NSURL *videoUrl;
    __weak NSURL *photoUrl;

//         Call private API to create the live photo
            self.livePhotoView.livePhoto = nil;
            self.livePhoto = nil;
            self.livePhoto = [[PHLivePhoto alloc] init];
            SEL initWithImageURLvideoURL = NSSelectorFromString(@"_initWithImageURL:videoURL:targetSize:contentMode:");
            if ([self.livePhoto respondsToSelector:initWithImageURLvideoURL]) {
                NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self.livePhoto methodSignatureForSelector:initWithImageURLvideoURL]];
                [invocation setSelector:initWithImageURLvideoURL];
                [invocation setTarget:self.livePhoto];
                [invocation setArgument:&(photoURL) atIndex:2];
                [invocation setArgument:&(videoUrl) atIndex:3];
                [invocation setArgument:&(targetSize) atIndex:4];
                [invocation setArgument:&(contentMode) atIndex:5];
                [invocation invoke];
            }

            // Set the live photo
            self.livePhotoView.livePhoto = self.livePhoto;
Run Code Online (Sandbox Code Playgroud)

最后,我得到了实时照片并在livePhotoView中显示它.然后我尝试保存或分享它.我使用Class UIActivityViewController.Like this:

  if …
Run Code Online (Sandbox Code Playgroud)

iphone photo ios ios9 phlivephoto

6
推荐指数
0
解决办法
857
查看次数

标签 统计

ios ×1

ios9 ×1

iphone ×1

phlivephoto ×1

photo ×1