ALAssetsLibrary ALAssetsLibraryAccessUserDeniedError

发布于 2024-11-04 21:17:37 字数 210 浏览 1 评论 0原文

当您第一次尝试访问用户的 ALAssetsLibrary 时,操作系统将向他们显示一个对话框,请求许可。如果他们不允许这样做,则会调用 failureBlock,并且将来始终会调用。有没有办法再次强制提示此授权请求?

我注意到在地图应用程序中,它们通知用户转到“设置”应用程序以使用按钮打开位置服务。但是,据我所知,无法以编程方式打开“设置”应用程序。我应该只显示如何打开定位服务的说明吗?

When you first try to access a user's ALAssetsLibrary, the OS will present them with a dialog asking for permission. If they do not allow this, a failureBlock will be called and will always be called in the future. Is there a way to force a prompt of this authorization request again?

I notice in the Maps app, that they inform the user to go to the Settings app to turn on location services with a button. However, there is no way that I know of to programmatically open the Settings app. Should I just display directions as to how to turn on the location services?

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

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

发布评论

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

评论(2

烟燃烟灭 2024-11-11 21:17:37

您无法以 Apple 批准的方式打开设置应用程序。
您所能期望的最好结果是捕获错误,然后显示 UIAlertView 或其他视图,并提供有关如何执行此操作的说明。查看最新版本的 Dropbox 应用程序,了解他们如何指导用户。

You can't open up the settings app in an Apple approved manner.
The best you can hope for is to trap the error and then display a UIAlertView or other view with instructions on how to do this. Take a look at the latest v. of the Dropbox app for an idea on how they instruct the user.

吻安 2024-11-11 21:17:37

当您尝试从代码访问库时,您可以使用错误处理程序来捕获错误并向用户显示一个警报,指定要执行的操作。

示例

failureBlock:^(NSError *error) {
    // error handling
    if (error.code == ALAssetsLibraryAccessGloballyDeniedError) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" 
            message:@"Error loading image... \nEnable Location Services in 'Settings -> Location Services'." 
            delegate:self cancelButtonTitle:@"OK" 
            otherButtonTitles:nil, nil];
        [alert show];
    } else if (error.code == ALAssetsLibraryAccessUserDeniedError) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" 
            message:[NSString stringWithFormat:@"Error loading image... \nEnable Location Services in 'Settings -> Location Services' for %@.", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]] 
            delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    } else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"Error loading image..." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    }
}

When you try to access the Library from your code, you can use the error handler to catch the error and display an alert specifying to the user what to do.

Example

failureBlock:^(NSError *error) {
    // error handling
    if (error.code == ALAssetsLibraryAccessGloballyDeniedError) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" 
            message:@"Error loading image... \nEnable Location Services in 'Settings -> Location Services'." 
            delegate:self cancelButtonTitle:@"OK" 
            otherButtonTitles:nil, nil];
        [alert show];
    } else if (error.code == ALAssetsLibraryAccessUserDeniedError) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" 
            message:[NSString stringWithFormat:@"Error loading image... \nEnable Location Services in 'Settings -> Location Services' for %@.", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]] 
            delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    } else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"Error loading image..." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文