如何监控 [CLLocationManager locationServicesEnabled] 何时更改?我需要类似 delegatenotification 的东西。

最佳答案

使用 CLLocationManager 的 delagte 方法

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status

这些是文档中的 CLAuthorizationStatus 描述:
    > typedef enum {
    >     kCLAuthorizationStatusNotDetermined = 0, // User has not yet made a choice with regards to this application
    >     kCLAuthorizationStatusRestricted,        // This application is not authorized to use location services.  Due
    >                                              // to active restrictions on location services, the user cannot change
    >                                              // this status, and may not have personally denied authorization
    >     kCLAuthorizationStatusDenied,            // User has explicitly denied authorization for this application, or
    >                                              // location services are disabled in Settings
    >     kCLAuthorizationStatusAuthorized         // User has authorized this application to use location services
} CLAuthorizationStatus;

关于ios - CLLocationManager locationServicesEnabled 事件发生变化,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20948983/

10-12 18:58