[英]ALAssetsLibrary custom location services permission alert iPhone
我正在使用ALAssetsLibrary
访问我的应用程序中的照片,并且当应用程序首次尝试访问照片时,它会请求位置服务的权限。 我想为该警报提供自定义消息,例如App希望访问您的照片而不是位置服务。
我在Google上搜索了很多内容,并且在堆栈溢出方面也进行了很多搜索,并且在用户拒绝了位置服务的权限但没有自定义消息的权限后,我找到了解决方案,我在许多InstaCollage,Pic Jointer等应用中都看到了这一点。
您不能(毫无疑问地在搜索中看到)。 那是系统消息,您不能覆盖它或避免它。 换句话说:没有就没有。
从iOS 6开始,您可以向警报对话框添加自定义文本(以指定要对数据进行的操作等)。要设置此描述文本,请添加
NSPhotoLibraryUsageDescription
键,然后将值设置为要显示的文本。
从开发人员文档中:
NSPhotoLibraryUsageDescription(字符串-iOS)描述了应用访问用户照片库的原因。 当系统提示用户允许访问时,此字符串将显示为对话框的一部分。 iOS 6.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];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.