iPhone - How to create a custom album and give custom names to photos in camera roll programmatically?

后端 未结 6 1369
孤城傲影
孤城傲影 2020-12-08 01:10

I am developing an iPhone photo application, so i need to create a separate album with a name \"My Album\" in camera roll and i need to save my UIImageView image with custom

6条回答
  •  我在风中等你
    2020-12-08 02:06

    You can try My below Method for Create Album for iOS 7 and iOS 8

    #define PHOTO_ALBUM_NAME @"AlbumName Videos"
    -(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");
        }];
    }}
    

提交回复
热议问题