将保存视频到照片库更改为 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 (将#修改为@)