2013-09-24 92 views
1

我已经开发了ios应用程序,它支持iPhone & iPad。monitoringDidFailForRegion只呼吁ipad

在该应用程序中,我集成了位置跟踪功能。

这是我如何实现它。

 //start monitoring for region for checked in location 
    CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(latitude,longtitude); 
    regionalMonitor = [[CLRegion alloc] initCircularRegionWithCenter:centerCoordinate  radius:REGIONAL_MONITOR_RADIOUS identifier:@"checkedIn"]; 
    [locationManager startMonitoringForRegion:regionalMonitor]; 


- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region 
{ 
     NSLog(@"didEnterRegion"); 
} 
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region 
{ 
     NSLog(@"didExitRegion"); 
} 
- (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error 
{ 
    NSLog(@"Region monitoring failed with error: %@", [error localizedDescription]); 

} 

这个方法在iphone应用程序中是完美的。但是当我尝试在ipad中执行它们时

monitoringDidFailForRegion 

方法将被调用。但它在ipad模拟器中完美运行。

有没有什么特别的原因,或者是这个面向设备的错误。因为如果我评论

[locationManager startMonitoringForRegion:regionalMonitor]; 

然后,它会不会叫monitoringDidFailForRegion方法

日志消息 - 地区监测失败,出现错误:操作无法完成。

感谢

回答

1

我敢肯定,地理界线不支持无线网络的iPad,或者至少旧的。

尝试打印[locationManager isMonitoringAvailableForClass:CLRegion]的值。如果这是真的(1),它应该工作。否则,它在当前设备上不受支持。

+0

你好,谢谢你的提示。我用这种方法检查了regionMonitoringAvailable。它返回false。但我真的需要这个东西的工作。对于这个 –

+0

@先生G:是的。我可以说,在iPad上禁用3g/4g的功能。 – Linuxios

+0

是的,我同意。我发现了一篇不错的文章,说ipad 2 wi-fi版本doent具有区域监视功能。 –