我的代码适用于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"]];
}
corelocation delegates ----
-(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");
}
谢谢。
答案 0 :(得分:-1)
最后我解决了这个......
- (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 = 100;
CLLocationCoordinate2D startLocation;
startLocation.latitude = 12.9667 ;
startLocation.longitude =77.5667 ;
CLCircularRegion * reg1 = [[CLCircularRegion alloc] initWithCenter:startLocation radius:rad identifier:@"location"];
[m_pLocatiomManager startMonitoringForRegion:reg1];
}
else
{
float rad = 100;
CLLocationCoordinate2D startLocation;
startLocation.latitude = 12.9667;
startLocation.longitude = 77.5667;
[m_pLocatiomManager startMonitoringForRegion:[[CLRegion alloc] initCircularRegionWithCenter:startLocation radius:rad identifier:@"location"]];
}