I used ELCImagePickerController in my app. but when we start our application first time and on Image gallery it will ask for accessing user location , if we don't allow to access user location to it then it will give error in UIAlertView and it wont show image gallery.
But after that if we go to setting app -> location services -> [turn on switch for access location for our app] then start app -> go to gallery page -> we can show image gallery in our app.
So my question is how can we show image gallery with ELCImagePickerController with location services turn off for our app or user don't allow to access location to our app. ELCImagePickerController can be downloadable at this LINK
Then find ELCAlbumPickerController.m file then go to View Did Load then this causes error alert when user location access turned off,
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 numberOfA开发者_运维问答ssets]);
// 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];
});
The answer is that you can't show the image gallery with ELCImagePickerController with location services turned off.
ELCImagePickerController uses the Assets Library Framework to access the device's photo album. Because this framework also gives access to the metadata of the photos - including location data - the user needs to grant permission for the app to use Location Services.
There's no way around this, except if you use the standard UIImagePickerController (but I assume that won't cover the requirements for your app)
精彩评论