2

私はこのコードをiOS 10より前に使用しましたが、うまくいきました。

    //Start monitoring
    CLLocationCoordinate2D centre;
    centre.latitude = [latZone floatValue];
    centre.longitude = [lonZone floatValue];

    [self.locationManager startMonitoringForRegion:[[CLCircularRegion alloc] initWithCenter:centre radius:[radiusZone floatValue] identifier:nameZone]];

しかし、iOS 10 バージョン以降、動作しなくなりました。didEnterRegion: didExitRegion: & didStartMonitoringForRegion: を呼び出しません。

何か案は?

4

1 に答える 1

1

info.plist に 2 つのキーを追加して、最終的に解決しました。

NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription

そして、直前にその2行を追加します:

    [self.locationManager requestAlwaysAuthorization];
    [self.locationManager requestWhenInUseAuthorization];
于 2016-11-28T14:25:02.037 に答える