我在我的应用中使用了ELCImagePickerController。但当我们第一次启动我们的应用程序时,在图片库上它会要求访问用户位置,如果我们不允许访问它的用户位置,那么它将在UIAlertView中给出错误,它不会显示图片库。
但在那之后,如果我们去设置应用程序->位置服务->打开开关为我们的应用程序访问位置,然后启动应用程序->转到画廊页面->,我们可以在我们的应用程序中显示图像画廊。
所以我的问题是,如果我们的应用程序关闭了定位服务,或者用户不允许访问我们的应用程序,我们如何使用ELCImagePickerController显示图片库。可通过此LINK下载ELCImagePickerController
然后找到ELCAlumPickerController.m文件,然后转到View Did Load,当用户位置访问关闭时,这会导致错误警报。
dispatch_async(dispatch_get_main_queue(), ^
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Group enumerator Block
void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
if (group == nil)
{
return;
}
[self.assetGroups addObject:group];
// Keep this line! w/o it the asset count is broken for some reason. Makes no sense
NSLog(@"count: %d", [group numberOfAssets]);
// Reload albums
[self performSelectorOnMainThread:@selector(reloadTableView) withObject:nil waitUntilDone:YES];
};
// Group Enumerator Failure Block
void (^assetGroupEnumberatorFailure)(NSError *) = ^(NSError *error) {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"Album Error: %@", [error description]] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
NSLog(@"A problem occured %@", [error description]);
};
// Enumerate Albums
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:assetGroupEnumberatorFailure];
[library release];
[pool release];
}); 发布于 2011-08-07 08:31:09
答案是你不能在关闭了定位服务的ELCImagePickerController下显示图片库。
ELCImagePickerController使用Assets Library Framework来访问设备的相册。由于此框架还允许访问照片的元数据-包括位置数据-用户需要授予应用程序使用位置服务的权限。
这是没有办法的,除非你使用标准的UIImagePickerController (但我假设这不能满足你的应用程序的要求)
https://stackoverflow.com/questions/6956808
复制相似问题