我的代码适用于iOS 6
. 但问题在于iOS7
只 didStartMonitoringForRegion
被调用,didEnterRegion 和 didEExitRegion 没有被调用....
- (void)viewDidLoad
{
[super viewDidLoad];
m_pLocatiomManager = [[CLLocationManager alloc] init];
m_pLocatiomManager.desiredAccuracy = kCLLocationAccuracyBest;
m_pLocatiomManager.delegate = self;
[m_pLocatiomManager startMonitoringSignificantLocationChanges];
[m_pLocatiomManager startUpdatingLocation];
}
添加区域的方法
if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0)
{
float rad = 200;
CLLocationCoordinate2D startLocation;
startLocation.latitude = 12.9667 ;
startLocation.longitude =77.5667 ;
CLCircularRegion * reg1 = [[CLCircularRegion alloc] initCircularRegionWithCenter:startLocation radius:rad identifier:@"location"];
[m_pLocatiomManager startMonitoringForRegion:reg1];
}
else
{
float rad = 200;
CLLocationCoordinate2D startLocation;
startLocation.latitude = 12.9667;
startLocation.longitude = 77.5667;
[m_pLocatiomManager startMonitoringForRegion:[[CLRegion alloc] initCircularRegionWithCenter:startLocation radius:rad identifier:@"location"]];
}
核心定位代表----
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSLog(@"region entered %@",region.description);
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
NSLog(@"region exit %@",region.description);
}
-(void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region
{
NSLog(@"region monitoring stared");
}
谢谢 。