我厌倦了找到这个问题,但无法理解为什么会发生这种情况,即位置管理器的委托方法didEnterRegion
或didExitRegion
从未被调用过。我在我的 iPhone 上进行了测试,但它不起作用。请告诉我我错过了什么。我的源代码是:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] 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; 坐标 = CLLocationCoordinate2DMake(24.004686, 74.554088); region=[[CLRegion alloc] initCircularRegionWithCenter:coord radius:dist identifier:@"emanuele"]; [经理 startMonitoringForRegion:region desiredAccuracy:10]; 返回是; } - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{ NSLog(@"输入区域。"); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"知道了..." message:@"您已输入位置。" 委托:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [警报显示]; // [警报发布]; } - (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { NSLog(@"didExitRegion"); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"知道了..." message:@"您已退出该位置。" 委托:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [警报显示]; // [警报发布]; }
任何人都可以弄清楚有什么问题吗?我搜索了许多演示和源代码,但大多数都didUpdateToLocation
以. 我也实施了,但它没有做的事情。请提供任何线索,为什么不调用这两种方法。或给我任何调用这些方法的链接,我没有找到这些方法的示例/来源。任何帮助将不胜感激。didEnter
didExit
didFailWithError