ALAssetsLibrary自定义位置服务权限提醒iPhone

时间:2013-02-11 06:58:54

标签: iphone alassetslibrary

我正在使用ALAssetsLibrary访问我的应用中的照片,当应用首次尝试访问照片时,它会询问位置服务的权限。我想为该警报提供自定义消息,例如App想要访问您的照片而不是位置服务。

我在谷歌搜索了很多,以及堆栈溢出,我在用户拒绝了位置服务权限后找到了解决方案,但是我没有在自定义消息中找到解决方案我在InstaCollage,Pic Jointer等许多应用程序中都看到了这个。

Pic Jointer Alert Image

3 个答案:

答案 0 :(得分:3)

你不能(正如你在搜索中看到的那样)。这是一条系统消息,您无法覆盖它或避免它。换句话说:不是没有。

答案 1 :(得分:2)

从iOS 6开始,您可以在警报对话框中添加自定义文本(以指定您对数据执行的操作等)。要设置此说明文字,请添加

NSPhotoLibraryUsageDescription

键入Info.plist并将值设置为您要显示的文本。

来自开发者文档:

NSPhotoLibraryUsageDescription(String - iOS)描述了应用访问用户照片库的原因。当系统提示用户允许访问时,此字符串将显示为对话框的一部分。 iOS 6.0及更高版本支持此密钥。

答案 2 :(得分:0)

你可以做一件事......

只需在应用程序加载时检查应用程序位置服务设置并显示自定义消息

#import <CoreLocation/CoreLocation.h>

-(void)showAlertForLocationServiceEnabled{


    BOOL locationAllowed = [CLLocationManager locationServicesEnabled];

    if (locationAllowed == NO) {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location Service Disabled!!!" 
                                                        message:@"Location Services is required for this application. Please enable Location Services" 
                                                       delegate:nil 
                                              cancelButtonTitle:@"OK" 
                                              otherButtonTitles:nil];
        [alert show];

    } 
}

-(void)checkAndNotifyLocationServiceAvailable{

    if (! ([CLLocationManager locationServicesEnabled]) || ( [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied)){

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location Service Disabled!!!" message:@"Location Services is required for this application. Please enable Location Services" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
        [alert show];


    }

}