浅述IOS开发之位置权限弹出框的闪烁
来源:爱站网时间:2020-10-22编辑:网友分享
开发中我们可以会遇到很多我们没有接触过的问题,但是这也正是我们成长的经历,本文是爱站技术频道小编介绍的浅述IOS开发之位置权限弹出框的闪烁,一起跟随小编过来看看吧。
开发中我们可以会遇到很多我们没有接触过的问题,但是这也正是我们成长的经历,本文是爱站技术频道小编介绍的浅述IOS开发之位置权限弹出框的闪烁,一起跟随小编过来看看吧。
当编码如下的时候,进入页面的时候可以看到UIAlertView弹出框出现一下,刚想点击的时候,他不见了,这个郁闷
CLLocationManager* _locationManager = [[CLLocationManager alloc] init];
_locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8) {
//由于IOS8中定位的授权机制改变 需要进行手动授权
//获取授权认证
[_locationManager requestWhenInUseAuthorization];
}
[_locationManager startUpdatingLocation];
究其原因是在arc下用完就被释放了,为了确保用户可以点击权限,只需要将 _locationManager 设置为属性即可,如下:
@property (strong, nonatomic) CLLocationManager* locationManager;
self.locationManager = [[CLLocationManager alloc] init];
_locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8) {
//由于IOS8中定位的授权机制改变 需要进行手动授权
//获取授权认证
[_locationManager requestWhenInUseAuthorization];
}
[_locationManager startUpdatingLocation];
如此再测试,完全没问题!
以上这篇文章就是爱站技术频道小编介绍的浅述IOS开发之位置权限弹出框的闪烁,希望能给大家一个参考,也希望大家多多支持js.aizhan.com。
