0

我的代码适用于iOS 6. 但问题在于iOS7didStartMonitoringForRegion被调用,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");
}

谢谢 。

4

1 回答 1

-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"]];
}
于 2014-02-20T06:51:21.843 回答