Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当位置服务选项发生变化时,如何观察和调用方法?例如,我的应用在后台运行定位服务,即设置中的选项设置为始终。如果用户在我的应用程序仍在运行时更改选项怎么办,如何观察更改并相应地在我的应用程序中进行更改?
实现 CLLocationManagerDelegate 方法
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
从文档:
“只要应用程序使用位置服务的能力发生变化,就会调用此方法。更改可能是因为用户允许或拒绝为您的应用程序或整个系统使用位置服务。”