开发者

startMonitoringForRegion not working

I want Location based Reminder when user reaches to 开发者_如何转开发certain region

For that I have writen followin code

CLLocationManager *manager=[[CLLocationManager alloc] init];
manager.desiredAccuracy=kCLLocationAccuracyBest;

manager.delegate=self;

CLLocationCoordinate2D loc;

loc.latitude=LReminder.lat;

loc.longitude=LReminder.lon;

CLRegion *region=[[CLRegion alloc] initCircularRegionWithCenter:loc
radius:LReminder.accuracy dentifier:LReminder.title];

CLLocationAccuracy acc=1.0;

[manager startMonitoringForRegion:region desiredAccuracy:acc];

[manager startMonitoringSignificantLocationChanges];

And for the manager delegate

-(void)locationManagerCLLocationManager *)manager didEnterRegionCLRegion *)region
{

    NSLog(@"didEnterRegion for %@",region.identifier);

    UIAlertView *alr=[[UIAlertView alloc] initWithTitle:@"Reminder didEnterRegion" 
message:region.identifier delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];

    [alr show];

    [alr release];
}

-(void)locationManagerCLLocationManager *)manager didExitRegionCLRegion *)region
{
    NSLog(@"didExitRegion for %@",region.identifier);

    UIAlertView *alr=[[UIAlertView alloc] initWithTitle:@"Reminder didExitRegion" message:region.identifier delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];

    [alr show];

    [alr release];
}

Problem is when I reach to reminder location it is not calling any of the delegates' methods

please help me


Without knowing more, I can only guess, but I'm betting you're not using an iPhone 4. Region monitoring currently only works on the iPhone 4.

You should be using:

[CLLocationManager regionMonitoringEnabled]

to determine if your device can use region monitoring.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜