6

CLLocationManager が起動間で監視対象リージョンを保持しないようにする方法はありますか? アプリを起動するたびに、監視対象地域の新しいセットを追加する必要があり、古いものは役に立たなくなります。それらが持続するのを防ぐか、起動時に古いものをすべてクリアする方法はありますか?

4

2 に答える 2

5

もちろん、現在監視されているすべてのリージョンをクリアできます。

+(void)clearRegionWatch
{
    for(CLRegion *region in [[WGLocation shared].locationManager monitoredRegions]){
        [[WGLocation shared].locationManager stopMonitoringForRegion:region];
    }
}

削除したい特定の識別子がある場合:

+(void)clearRegionWatchForKey:(NSString *)key
{
    for(CLRegion *region in [[WGLocation shared].locationManager monitoredRegions]){
        if([region.identifier isEqualToString:key]){
            [[WGLocation shared].locationManager stopMonitoringForRegion:region];
        }
    }
}

関数の内部をアプリケーションの適切な場所にコピーできます。共有マネージャー クラスからコピーしました。

于 2014-08-05T22:02:58.807 に答える