0
我想从新应用程序中保存所有图像(使用我的应用程序名称)。所以我在我的项目中使用了断言库。它在ios 7中运行良好,但在ios8和后续版本中运行良好。当用户从照片中删除相册时,出现错误,断言库无法在ios8中重新创建具有相同名称的新相册。任何人都有这个解决方案?由于AssetsLibrary框架无法在iOS 8中删除相册后工作
我想从新应用程序中保存所有图像(使用我的应用程序名称)。所以我在我的项目中使用了断言库。它在ios 7中运行良好,但在ios8和后续版本中运行良好。当用户从照片中删除相册时,出现错误,断言库无法在ios8中重新创建具有相同名称的新相册。任何人都有这个解决方案?由于AssetsLibrary框架无法在iOS 8中删除相册后工作
你可以试试下面我为法适用于iOS 7和iOS 8
#define PHOTO_ALBUM_NAME @"AlbumName Videos"
#pragma mark - Create Album
-(void)createAlbum{
// PHPhotoLibrary_class will only be non-nil on iOS 8.x.x
Class PHPhotoLibrary_class = NSClassFromString(@"PHPhotoLibrary");
if (PHPhotoLibrary_class) {
// iOS 8..x. . code that has to be called dynamically at runtime and will not link on iOS 7.x.x ...
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
[PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:PHOTO_ALBUM_NAME];
} completionHandler:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"Error creating album: %@", error);
}else{
NSLog(@"Created");
}
}];
}else{
[self.library addAssetsGroupAlbumWithName:PHOTO_ALBUM_NAME resultBlock:^(ALAssetsGroup *group) {
NSLog(@"adding album:'Compressed Videos', success: %s", group.editable ? "YES" : "NO");
if (group.editable == NO) {
}
} failureBlock:^(NSError *error) {
NSLog(@"error adding album");
}];
}}
通过这个link.it可以帮助you.http创建相册://stackoverflow.com/questions/26003211/assetslibrary- framework-broken-on-ios-8 – BHUMICA 2014-11-24 05:27:54
是的,它正在工作,但我无法理解完整的代码。所以当我试图保存照片时,它又创建了一张新专辑,那么你能给我一个标准代码吗?请保留相册名称为照片应用 并感谢您重播我 – user3418619 2014-11-25 09:45:21