CoreLocation — проблема мониторинга региона в iOS 7

Мой код работает для 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");
}

Спасибо .


person Shaik Riyaz    schedule 27.01.2014    source источник
comment
Вы тестируете это на устройстве?   -  person Gad    schedule 27.01.2014
comment
симулятор с использованием файлов gpx   -  person Shaik Riyaz    schedule 27.01.2014
comment
Я бы попробовал протестировать его на устройстве, поскольку для мониторинга региона используются вышки сотовой связи и Wi-Fi для определения местоположения. У меня также были проблемы при тестировании этого на симуляторе. Кроме того, если вы еще этого не сделали, я предлагаю вам реализовать locationManager:monitoringDidFailForRegion:withError, чтобы убедиться, что все работает правильно.   -  person Gad    schedule 27.01.2014
comment
@GadMarkovits прав, поведение симулятора непредсказуемо, когда вы пытаетесь выполнить мониторинг региона. Я удивлен, что это работает на iOS6. Во-вторых, не используйте эту систему для проверки версии, используйте систему, предоставленную Apple developer.apple.com/library/ios/documentation/userexperience/ посмотрите внизу   -  person Andrea    schedule 27.01.2014


Ответы (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"]];
}
person Shaik Riyaz    schedule 20.02.2014
comment
Извините, а чем отличается? - person Daniel; 11.06.2014
comment
@Daniel CLCircularRegion * reg1 = [[CLCircularRegion alloc] initWithCenter:startLocation radius:идентификатор rad:@location]; // создание объекта с использованием initWithCenter:radius:identifier во втором случае - person Shaik Riyaz; 11.06.2014
comment
@RIYAZ, не могли бы вы поделиться кодом, связанным с SignificantLocationChanges. Поскольку я не могу заставить его работать на iOS7. т. е. если мое приложение не активно, SignificantLocationChanges не работает. аналогично проблеме, упомянутой здесь, stackoverflow.com/questions/19048526/ - person Azhar Bandri; 04.09.2014