Save Photos to Custom Album in iPhones Photo Library

后端 未结 5 1076
无人共我
无人共我 2020-11-30 17:49

I\'m trying to create a custom album in the Photo Library of an iPhone and then save photos that I\'ve taken with the camera, or chosen from the phones Camera Roll to that c

5条回答
  •  情深已故
    2020-11-30 18:35

    The code from @Scott Allen was close but would not save the image for me the first time. So if I did not already have the album created, the image would not save. My solution was to move this snippet that creates the album to the app delegate didFinishLaunchingWithOptions:

        NSString *albumName=@"album name";
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    [library addAssetsGroupAlbumWithName:albumName
                             resultBlock:^(ALAssetsGroup *group) {
                                 NSLog(@"added album:%@", albumName);
                             }
                            failureBlock:^(NSError *error) {
                                NSLog(@"error adding album");
                            }];
    

提交回复
热议问题