I try to make 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;
At last,I get the live photo and show it in the livePhotoView.Then I try to save it or share it.I use Class UIActivityViewController.Like this:
if (self.livePhoto) {
UIActivityViewController *activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:@[self.livePhotoView.livePhoto]
applicationActivities:nil];
[self presentViewController:activityViewController
animated:YES
completion:^{
// ...
}];
}
When I share live photo,what I share is just still image.When I choose to save live photo,I can't find anything in album.I search this in many places.I just find some informations in this https://github.com/genadyo/LivePhotoDemo/issues/3. But it didn't solve my problem.
I found an app can do it in AppStore.But I can't understand how it works.https://itunes.apple.com/cn/app/livemaker-free-for-live-photo/id1053967828?mt=8