important The user has the option of denying an application’s access
to the location service data. During its initial uses by an
application,the Core Location framework prompts the user to confirm
that using the location service is acceptable. If the user denIEs the
request,the CLLocationManager object reports an appropriate error to
its delegate during future requests.
我确实得到了我的委托的错误,并且CLLocationManager上的locationServicesEnabled的值是正确的.缺少的唯一部分是向用户提示有关权限的提示.这发生在我的开发MPB和朋友MBP上.我们都不知道什么是错的.
有没有人碰到这个?
相关代码:
_locationManager = [CLLocationManager new]; [_locationManager setDelegate:self];[_locationManager setDesiredAccuracy:kCLLocationAccuracyKilometer];...[_locationManager startUpdatingLocation];解决方法 我发现在Mac上,当你通过调用启动位置服务时
[locationManager startUpdatingLocation];
它会触发
- (voID)locationManager:(CLLocationManager *)manager dIDChangeAuthorizationStatus:(CLAuthorizationStatus)status
状态为
kCLAuthorizationStatusNotDetermined
如果您观察此状态,然后再次开始更新该位置,则会触发权限对话框:例如,
- (voID)locationManager:(CLLocationManager *)manager dIDChangeAuthorizationStatus:(CLAuthorizationStatus)status{ switch (status) { case kCLAuthorizationStatusAuthorized: NSLog(@"Location Services are Now Authorised"); [_locationManager startUpdatingLocation]; break; case kCLAuthorizationStatusDenIEd: NSLog(@"Location Services are Now DenIEd"); break; case kCLAuthorizationStatusNotDetermined: NSLog(@"Location Services are Now Not Determined"); // We need to triger the OS to ask the user for permission. [_locationManager startUpdatingLocation]; [_locationManager stopUpdatingLocation]; break; case kCLAuthorizationStatusRestricted: NSLog(@"Location Services are Now Restricted"); break; default: break; }}总结
以上是内存溢出为你收集整理的macos – Mac CoreLocation Services不要求权限全部内容,希望文章能够帮你解决macos – Mac CoreLocation Services不要求权限所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)