gpt4 book ai didi

iphone - 如何访问我在相机应用中保存的照片的相册?

转载 作者:行者123 更新时间:2023-12-01 18:30:05 24 4
gpt4 key购买 nike

我已使用代码将照片保存到我的应用程序中的自定义相册

[library saveImage:self.capturedImg toAlbum:@"FunCam" withCompletionBlock:^(NSError *error) {
if (error!=nil) {
NSLog(@"Big error: %@", [error description]);
}
}];

现在,当用户单击某个按钮并在 View 中显示它们时,我想检索保存到该相册的所有照片,如相机应用程序(iphone 上的默认应用程序)显示

请帮助我,我该怎么做?

提前致谢

最佳答案

试试这些方法...

-(void)loadNewLibraryImages
{
self.assetGroups = [[NSMutableArray alloc] init];
// Group enumerator Block
dispatch_async(dispatch_get_main_queue(), ^
{
void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
if (group == nil)
{
return;
}
if ([[group valueForProperty:ALAssetsGroupPropertyName] isEqualToString:@"YOUR ALBUM NAME"]) {
[self.assetGroups addObject:group];
[self loadImages];
return;
}

if (stop) {
return;
}

};

// Group Enumerator Failure Block
void (^assetGroupEnumberatorFailure)(NSError *) = ^(NSError *error) {

UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"ERROR" message:[NSString stringWithFormat:@"No Albums Available"] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
};

// Enumerate Albums
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:assetGroupEnumberatorFailure];


});


}

-(void)loadImages
{
//for (ALAssetsGroup *assetGroup in self.assetGroups) {
// for (int i = 0; i<[self.assetGroups count]; i++) {

ALAssetsGroup *assetGroup = [self.assetGroups objectAtIndex:0];
NSLog(@"ALBUM NAME:;%@",[assetGroup valueForProperty:ALAssetsGroupPropertyName]);

[assetGroup enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result == nil)
{
return;
}
UIImage *img = [UIImage imageWithCGImage:[[result defaultRepresentation] fullScreenImage] scale:1.0 orientation:(UIImageOrientation)[[result valueForProperty:@"ALAssetPropertyOrientation"] intValue]];

}];

// }
}

希望他们会有所帮助....

关于iphone - 如何访问我在相机应用中保存的照片的相册?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10040731/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com