iOS 判断当前APP是否开启定位服务,未开通点击确定进入设置里进行设置
2017-03-13 17:45
676 查看
首先我们要倒入一个官方的头文件
#import <MapKit/MapKit.h>
接下俩
要遵守协议 <CLLocationManagerDelegate>
接下来便是代码了
CLAuthorizationStatus status = [CLLocationManagerauthorizationStatus];
if (kCLAuthorizationStatusDenied == status ||kCLAuthorizationStatusRestricted
== status) {
//这里是未开通时调用的方法
[selfcreatOrderAlertView];
}
-(void)creatOrderAlertView{
UIAlertView * alert = [[UIAlertViewalloc]
initWithTitle:@"提示"
message:@"需要访问你当前位置,请打开你的位置服务"
af2b
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"确定",nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex ==0) {//取消
}elseif (buttonIndex
==1){//通过下列方法变进入设置里设置权限
NSURL *settingsURL = [NSURLURLWithString:UIApplicationOpenSettingsURLString];
[[UIApplicationsharedApplication]
openURL:settingsURL];
}
}
#import <MapKit/MapKit.h>
接下俩
要遵守协议 <CLLocationManagerDelegate>
接下来便是代码了
CLAuthorizationStatus status = [CLLocationManagerauthorizationStatus];
if (kCLAuthorizationStatusDenied == status ||kCLAuthorizationStatusRestricted
== status) {
//这里是未开通时调用的方法
[selfcreatOrderAlertView];
}
-(void)creatOrderAlertView{
UIAlertView * alert = [[UIAlertViewalloc]
initWithTitle:@"提示"
message:@"需要访问你当前位置,请打开你的位置服务"
af2b
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"确定",nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex ==0) {//取消
}elseif (buttonIndex
==1){//通过下列方法变进入设置里设置权限
NSURL *settingsURL = [NSURLURLWithString:UIApplicationOpenSettingsURLString];
[[UIApplicationsharedApplication]
openURL:settingsURL];
}
}
相关文章推荐
- ios 里如何判断当前应用的定位服务是否可用
- ios 判断当前应用的定位服务是否可用
- 判断APP用户手机是否开启了定位服务
- ios 里如何判断当前应用的定位服务是否可用
- 判断APP用户手机是否开启了定位服务
- ios 里如何判断当前应用的定位服务是否可用
- ios 判断用户是否开启定位权限并跳转设置
- 转 ios 里如何判断当前应用的定位服务是否可用
- ios 里如何判断当前应用的定位服务是否可用
- IOS 判断定位服务是否开启代码
- ios 里如何判断当前应用的定位服务是否可用
- iOS开发 判断用户是否开启了定位服务
- 转 ios 里如何判断当前应用的定位服务是否可用
- ios 点击网页页面判断是否安装app并打开
- ios判断是否开启了定位
- 安卓开发,点击通知栏进入指定页面及判断App是否启动
- 判断一个坐标点是否在一个无规则的多边形内 (iOS定位服务与地图应用开发:高德地图开发)
- iOS 9.0之后调用支付宝或者微信支付,点击右上角返回按钮会当前APP后订单状态的判断
- 关于iOS地图定位中点击设置->隐私->定位服务 闪退问题