2016-07-19 3 views
1

ich Code unten bin mit einem Video zu Foto-Bibliothek zu speichern.iOS 9 PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL: nicht mit dem Fehlercode -1

NSString *ss = [finalVideoURL path]; 

    __block PHObjectPlaceholder *placeholder; 


    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ 
     PHAssetChangeRequest* createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:[NSURL fileURLWithPath:ss]]; 
     _placeholder = [createAssetRequest placeholderForCreatedAsset]; 

    } completionHandler:^(BOOL success, NSError *error) { 
     if (success) 
     { 

      NSLog(@" success iOS 9"); 
     } 
     else 
     { 
      NSLog(@"%@", error); 
     } 
    }]; 

Dieser Code funktioniert gut mit iOS 8.x. aber es funktioniert nicht mit Fehlercode -1 in iOS 9.x. Der Fehler ist

`Error Domain=NSCocoaErrorDomain Code=-1 "(null)"` 

Jede Idee zu diesem Verhalten in iOS 9.? Jede Hilfe wird geschätzt! Dank

Antwort

0

Sie nur in Ihrem eigenen Album sparen können Sie benötigen ein Fotoalbum

//获取自定义相册 
- (PHAssetCollection *)getAPPCollection { 
// Getting the app album if any: 找是否已经创建自定义相册 
PHFetchResult<PHAssetCollection *> *collectionResult = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil]; 
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; 
for (PHAssetCollection *collection in collectionResult) { 
    if ([collection.localizedTitle isEqualToString:appName]) { 
     return collection; 
    } 
} 

// Creating the album: 新建自定义相册 
__block NSString *collectionId = nil; 
NSError *error = nil; 
[[PHPhotoLibrary sharedPhotoLibrary] performChangesAndWait:^{ 
    collectionId = [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:appName].placeholderForCreatedAssetCollection.localIdentifier; 
} error:&error]; 
if (error) { 
    NSLog(@"创建相册:%@失败", appName); 
    return nil; 
} 
return [PHAssetCollection fetchAssetCollectionsWithLocalIdentifiers:@[collectionId] options:nil].lastObject; 
} 
+0

Bitte stellen Sie die richtige Vertiefung des Codes erstellen ... http://meta.stackexchange.com/questions/ 22186/how-do-i-Format-meine-Code-Blöcke –