私はこれに関する問題を見つけるのにうんざりしていますが、ロケーションマネージャーのデリゲートメソッドが呼び出されない、didEnterRegionまたはdidExitRegion呼び出されないためになぜこれが起こるのかを理解できませんでした。iPhoneでこれをテストしましたが、うまくいきません。私が欠けているものを教えてください。私のソースコードは次のとおりです。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] 境界]] autorelease];
// アプリケーションの起動後にカスタマイズするポイントをオーバーライドします。
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
manager = [[CLLocationManager alloc] init];
manager.delegate = 自己;
距離 = 100;
coord = CLLocationCoordinate2DMake(24.004686, 74.554088);
region=[[CLRegion alloc] initCircularRegionWithCenter:coord radius:dist identifier:@"emanuele"];
[manager startMonitoringForRegion:region desiredAccuracy:10];
はいを返します。
}
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{
NSLog(@"地域を入力してください。");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"わかりました..." message:@"場所を入力しました。" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[アラートショー];
// [アラート解除];
}
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
NSLog(@"didExitRegion");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"わかった..." message:@"ロケーションを終了しました。" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[アラートショー];
// [アラート解除];
}
誰が何が悪いのか理解できますか?? 私は多くのデモとソースコードを検索しましたが、それらのほとんどはdidUpdateToLocation私の場合は で終わりますが、 と に問題がdidEnterありdidExitます。私も実装しましたdidFailWithErrorが、それはしません。これら 2 つのメソッドが呼び出されない理由を教えてください。または、これらのメソッドを呼び出すリンクを教えてください。これらのメソッドの例/ソースは見つかりませんでした。どんな助けでも大歓迎です。