我一直在尝试在iPhone上进行区域监视时遇到问题。首先,我从来没有(甚至没有)在我的iPhone 4设备上有didEnterRegion
或didExitRegion
火。iOS:用模拟器监控区域
我决定在模拟器上测试,而不是浪费工作时间在市中心漫步(尽管我希望在真实场景中看到这项工作)。首先,模拟器在精确度方面没什么问题,你会认为它非常准确(或者我错了吗?)。
下被调试菜单
我终于didEnterRegion
火下改变位置在模拟器上完成的,虽然我是从有问题的一圈约8个城市街区。当我退出该地区didExitRegion
连续发射约200次。这是一个模拟器错误?我几乎准备放弃这一点,并开始自己计算这些东西,因为它变得很荒谬。
任何想法,为什么准确性如此糟糕,为什么我的方法被解雇这么多次?
下面是相关代码:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
CLLocationDegrees latitude = 45.50568;
CLLocationDegrees longitude = -73.57033;
CLLocationCoordinates2D centerCoordinate = CLLocationCoordinate2DMake(latitude, longitude);
CLLocationDistance regionRadius = 200.0;
CLRegion *myRegion = [[CLRegion alloc] initCircularRegionWithCenter:centerCoordinate radius:regionRadius identifier:@"aroundWork"];
[locationManager startMonitoringForRegion:myRegion];
return YES:
}
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSLog(@"Entered region: %@", region.identifier);
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
NSLog(@"Exited region: %@", region.identifier);
}
没有看到任何你的代码,我们没有办法知道你在做什么是正确的(可能不是像许多其他人使用这些方法没有问题)或模拟器的错误。 – sosborn 2013-04-23 19:05:09