【问题标题】:startMonitoringForRegion not workingstartMonitoringForRegion 不工作
【发布时间】:2010-09-08 06:30:54
【问题描述】:

当用户到达某个区域时,我想要基于位置的提醒

为此我编写了以下代码

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];
}

问题是当我到达提醒位置时,它没有调用任何代表的方法

请帮帮我

【问题讨论】:

  • 你找到解决这个问题的方法了吗?

标签: objective-c cllocationmanager


【解决方案1】:

不知道更多,我只能猜测,但我打赌你没有使用 iPhone 4。区域监控目前仅适用于 iPhone 4。

你应该使用:

[CLLocationManager regionMonitoringEnabled]

确定您的设备是否可以使用区域监控。

【讨论】:

  • 你应该使用[CLLocationManager regionMonitoringAvailable]来测试设备是否可以根据文档使用区域监控
猜你喜欢
  • 1970-01-01
  • 2011-05-08
  • 1970-01-01
  • 2013-09-11
  • 2011-08-02
  • 1970-01-01
  • 2013-12-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多