0
我想在我的應用程序中使用iOS didEnterRegion方法。我有一個tableView,將用戶傳遞給profileViewController。在profileViewController的viewDidLoad方法中,我有一組緯度和經度座標,我將其存儲爲一個區域,然後我開始監視該區域。didEnterRegion方法只觸發最近區域
此代碼有效,但didEnterRegion方法僅觸發加載的最後一個配置文件。例如,如果我查看配置文件A並開始監控配置文件A的區域,那麼我查看配置文件B,如果我輸入配置文件B的區域,則只會觸發didEnterRegion。
有誰知道可能會發生什麼錯誤?謝謝!
下面是在profileViewController的viewDidLoad方法的代碼:
NSString *latOne = placeLatitude;
NSString *lngOne = placeLongitude;
NSString *radiusOne = @"100";
CLLocationDegrees latTwo = [latOne doubleValue];
CLLocationDegrees lngTwo =[lngOne doubleValue];
CLLocationDistance radiusTwo = [radiusOne doubleValue];
CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(latTwo, lngTwo);
CLRegion *grRegion = [[CLRegion alloc] initCircularRegionWithCenter:coordinates
radius:radiusTwo identifier:[NSString stringWithFormat:@"grRegion%i", 1]];
[locationManager startMonitoringForRegion:grRegion];
我didEnterRegion也是在profileViewController
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
//local notification code is in here
}