0

この地域モニターの精度は非常に悪いです。誰でもこの問題を解決できますか?ソースコードのリポジトリはこちら: https://github.com/robert-yi-jones/RegionTrigger

マップの中心である CLLocationCoordinate2D 変数を作成しました。次に、座標を基に半径 100 メートルの領域を設定します。

CLLocationCoordinate2D *targetPoint =
        [[CLLocation alloc] initWithLatitude:MapView.centerCoordinate.latitude
                                   longitude:MapView.centerCoordinate.longitude];
targetRegion = [[CLCircularRegion alloc] initWithCenter:targetPoint.coordinate
                                                 radius:300
                                             identifier:@"My Circle Region"];
[locationManager startMonitoringForRegion:targetRegion];

しかし、監視を開始した領域がうまく機能していないようです。

/*
 *  locationManager:didEnterRegion:
 *
 *  Discussion:
 *    Invoked when the user enters a monitored region.  This callback will be invoked for every allocated
 *    CLLocationManager instance with a non-nil delegate that implements this method.
 */
- (void)locationManager:(CLLocationManager *)manager
         didEnterRegion:(CLRegion *)region{
    if ([region.identifier isEqualToString:@"My Circle Region"]) {
        [self showAlertWithTitle:@"Entering a Region"
                         Message:region.identifier];
    }
}

/*
 *  locationManager:didExitRegion:
 *
 *  Discussion:
 *    Invoked when the user exits a monitored region.  This callback will be invoked for every allocated
 *    CLLocationManager instance with a non-nil delegate that implements this method.
 */
- (void)locationManager:(CLLocationManager *)manager
          didExitRegion:(CLRegion *)region{
    if ([region.identifier isEqualToString:@"My Circle Region"]) {
        [self showAlertWithTitle:@"Exiting a Region"
                         Message:region.identifier];
    }
}

セットアップ リージョンから約 6 KM 離れた場所に座標が切り替わったときにのみ、それは私に気付きます。

リージョン モニターのサンプル コードを持っている人はいますか? バグが本当に見つからない!

4

1 に答える 1