ELCImagePickerController 不允许访问用户位置

发布于 2024-11-28 03:02:55 字数 2010 浏览 1 评论 0原文

我在我的应用程序中使用了 ELCImagePickerController。 但是当我们第一次启动应用程序并在图片库上时,它会要求访问用户位置,如果我们不允许访问用户位置,那么它会在 UIAlertView 中给出错误,并且不会显示图片库。

但之后如果我们去设置应用程序 ->定位服务-> [打开我们应用程序访问位置的开关]然后启动应用程序 ->进入图库页面 ->我们可以在我们的应用程序中显示图片库。

所以我的问题是,我们如何使用 ELCImagePickerController 显示图片库,并为我们的应用程序关闭位置服务,或者用户不允许访问我们的应用程序的位置。 ELCImagePickerController 可以在此下载 LINK

然后找到 ELCAlbumPickerController.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];
});    

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 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];
});    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

皇甫轩 2024-12-05 03:02:55

答案是,在位置服务关闭的情况下,您无法使用 ELCImagePickerController 显示图片库。

ELCImagePickerController 使用资产库框架来访问设备的相册。由于该框架还允许访问照片的元数据(包括位置数据),因此用户需要授予应用程序使用位置服务的权限。

没有办法解决这个问题,除非您使用标准 UIImagePickerController (但我认为这不会满足您的应用程序的要求)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文