如何解决将保存视频到照片库更改为 PHPhotoLibrary
我有一个要更新的 iOS 应用。在过去,我使用了 UIPhotoLibrary 但现在我必须切换到 PHPhotoLibray。我已经完成了一些更新,但我被卡住了。
有人可以帮助我。
这是我的代码
PHPhotoLibrary *library = [[PHPhotoLibrary alloc] init];
CLLocation *loc = [[CLLocation alloc]initWithLatitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude];
NSMutableDictionary *Metadata = [NSMutableDictionary dictionaryWithDictionary:[info objectForKey:UIImagePickerControllerMediaMetadata]];
NSLog(@"Metadata;%@",[Metadata description]);
NSMutableDictionary *MetadataAsMutable = [Metadata mutablecopy];
NSMutableDictionary *GPSDictionary = [[MetadataAsMutable objectForKey:(Nsstring *)kCGImagePropertyGPSDictionary]mutablecopy];
if(!GPSDictionary)
{
GPSDictionary = [NSMutableDictionary dictionary];
}
NSError *error = nil;
[MetadataAsMutable setobject:loc forKey:(Nsstring *)kCGImagePropertyGPSDictionary];
movieData = [NSKeyedArchiver archivedDataWithRootObject:MetadataAsMutable requiringSecureCoding:NO error:&error];
NSData *myData = [NSKeyedArchiver archivedDataWithRootObject:MetadataAsMutable requiringSecureCoding:NO error:&error];
NSURL *assetURL2 = [NSURL URLWithDataRepresentation:myData relativetoURL:movieURL];
NSLog(@"netadataAsMutable;%@",[MetadataAsMutable description]);
//正确此处错误说“PHPhotoLibrary”没有可见的@interface 声明选择器“writeVideoAtPathToSavedPhotosAlbum:completionBlock:” 我用什么?
[library writeVideoAtPathToSavedPhotosAlbum:(NSURL *)movieURL
completionBlock:^(NSURL *assetURL,NSError *error){
if (error) {
NSLog(@"Save video fail:%@",error);
} else {
NSLog(@"Save video succeed.");
NSLog(@"assetURL2%@",assetURL2);
[self getsavedvideo];
}
}];
//RIGHT HERE SAYS 没有可见的@interface for 'PHPhotoLibrary' 声明了选择器 'assetForURL:resultBlock:failureBlock:' 我要改变什么?
[library assetForURL:movieURL resultBlock:^(PHAsset *asset) {
// If asset exists
if (asset) {
NSLog(@"asset exists");
} else {
NSLog(@"no asset exists");
}
} failureBlock:^(NSError *error) {
// Type your code here for failure (when user doesn't allow location in your app)
}];
}
我真的很感谢大家的帮助。谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。