startMonitoringForRegion无法正常工作 [英] startMonitoringForRegion not working
本文介绍了startMonitoringForRegion无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要在用户到达特定区域时基于位置的提醒
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];
对于经理代表
-(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
请帮助我
推荐答案
我不知道更多,只能猜测,但我敢打赌,您未使用iPhone4。区域监视当前仅在iPhone 4上有效。
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.
您应使用:
[CLLocationManager regionMonitoringEnabled]
确定您的设备是否可以使用区域监视。
to determine if your device can use region monitoring.
这篇关于startMonitoringForRegion无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文