3

I am retrieving photos from the photo library using ELCImagePickerController. That works fine in the iPad simulator that shows photos from the photo library. But it does not work on iPad devices.

That shows a failure error means there are no photos, even though the device has photos.

I used the following

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

Works for simulators, but not for iPad devices.

Can anybody reply, what's the problem there?

AmerllicA
  • 29,059
  • 15
  • 130
  • 154
Steve Gear
  • 757
  • 2
  • 16
  • 44
  • 1
    What is the actual error being received by your `assetGroupEnumberatorFailure` block? – Anomie Sep 06 '11 at 12:46
  • Hi Anomie ,that message shows in the alert as -- > Album Error:Error Domain:ALAssetsLibraryErrorDomain Code=-3311 "User denied access" UserInfo=0x147180{NSLocalizedFailureReason=The user has denied the application access to their media.,NSLocalizeddescription=User denied access} .. I know this means there are no photos in the photo library . but there are photos in my device. Can you please tell me why if you know – Steve Gear Sep 06 '11 at 13:33

1 Answers1

5

The error message you are receiving indicates that the user has denied your program access to the photo library, by denying access to Location Services. For some unknown reason Apple uses Location Services permission to control access to the photo library via the AssetsLibrary framework. Go into the Settings application and make sure that Location Services is on and that it is allowed for your application.

My guess as to why they did this is that they are concerned that some app might somehow bypass Location Services being denied by loading all the photos from the library and looking for EXIF geotagging data.

Anomie
  • 92,546
  • 13
  • 126
  • 145
  • But how to know the user that Location Services is on, is there way to avoid this? – Steve Gear Sep 07 '11 at 07:28
  • 2
    @Chakradhar: You can use [CLLocationManager](http://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html) to have a little more control over things, but mainly you just have to check if you get an NSError with domain `ALAssetsLibraryErrorDomain` and code `ALAssetsLibraryAccessUserDeniedError` or `ALAssetsLibraryAccessGloballyDeniedError`. – Anomie Sep 07 '11 at 10:25
  • @Anomie,Steve Gear: I have also used Assetslibrary in my application and I am facing same problem, can you give me idea or sample code so that i can over come from this issue. Thanks In Advance! – Gamer Sep 19 '12 at 02:17