How to save homemade live photos in an album?

I am trying to take live photos with a jpg file and a mov file. Like this:

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; 

Finally, I get a live photo and show it in livePhotoView. Then I try to save it or share it. I am using the UIActivityViewController class. In a similar way:

  if (self.livePhoto) { UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[self.livePhotoView.livePhoto] applicationActivities:nil]; [self presentViewController:activityViewController animated:YES completion:^{ // ... }]; } 

When I share live photography, what I share is just an image. When I choose to save a live photo, I can not find anything in the album. I look for it in many places. I just find the information in this https://github.com/genadyo/LivePhotoDemo/issues/3 . But that did not solve my problem.

I found that the application can do this in the AppStore. But I can’t understand how this works. https://itunes.apple.com/cn/app/livemaker-free-for-live-photo/id1053967828?mt=8

+5
source share

Source: https://habr.com/ru/post/1235512/


All Articles