做定位相关功能,这里记录一下,已亲测,完美应对iOS8 9 10。
iOS10之前可以使用:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"]];
上述方法在iOS10时废除:
所以iOS10之后应该这样使用:
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"]
options:[NSDictionary dictionary]
completionHandler:nil];
完整使用方法:
CGFloat systemVersion = [[UIDevice currentDevice].systemVersion floatValue];
if (systemVersion < 10) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"]];
}else{
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"]
options:[NSDictionary dictionary]
completionHandler:nil];
}
网友评论