【问题标题】:Getting error when trying to update location尝试更新位置时出错
【发布时间】:2011-07-20 07:36:17
【问题描述】:

我尝试更新用户当前位置,我的相关代码是这样的:

#pragma mark-
#pragma mark CLLocationManagerDelegate
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
    float latitude=newLocation.coordinate.latitude;
    float longitude=newLocation.coordinate.longitude;
    TopStationAppDelegate *topStation=(TopStationAppDelegate *)[[UIApplication sharedApplication]delegate];
    topStation.latitudeUtilisateur=latitude;
    topStation.longitudeUtilisateur=longitude;
    NSLog(@"%f",latitude);
    NSLog(@"%f",longitude);
    NSLog(@"position updated");
    //[locationManager stopUpdatingLocation];

}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 
{
    NSLog(@"didFailWithError: %@", error);
}

didFailWithError 方法将这个堆栈返回给我:

ERROR,Time,332840118.515,Function,"void CLClientHandleDaemonDataRegistration(__CLClient*, mach_port_t, const CLDaemonCommToClientRegistration*, const __CFDictionary*)",server did not accept client registration 2
2011-07-20 09:35:18.525 TopStation[764:207] didFailWithError: Error Domain=kCLErrorDomain Code=1 "The operation couldn’t be completed. (kCLErrorDomain error 1.)"

你能帮我吗?提前谢谢:)

【问题讨论】:

  • 你在做模拟器吗?
  • 是的,我目前在模拟器上测试 :)
  • cllocationmanager 无法在模拟器上运行,这就是您收到此错误的原因

标签: ios cllocationmanager


【解决方案1】:

正如前面的评论所说,您使用的模拟器版本不适用于基于位置的东西。您最好的选择(如果您是付费开发者)是下载新的 Xcode 4.2,它允许您操作位置数据并实际使用模拟器。

如果您不是付费开发者,则必须在设备上进行测试。

如果您是付费开发者,请查看此帖子 here 以获取一些链接。您可以查看 WWDC 视频,了解如何使用模拟器进行位置测试。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多