【问题标题】:MKMapView didUpdateUserLocation not updatingMKMapView didUpdateUserLocation 未更新
【发布时间】:2011-03-11 01:16:08
【问题描述】:

我有一个带有地图的应用程序,并希望在更新时缩放到当前位置。

我使用-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation 委托方法来了解用户位置何时更新。

现在正在调用模拟器方法。但是当我在设备(iphone 2g)上测试它时,地图上的位置会更新,但是根本没有调用“didUpdateUserLocation”方法,委托方法“mapViewWillStartLocatingUser”也是如此。

系统询问我是否允许为应用获取我的位置并开始显示我的位置,但是

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
NSLog(@"didUpdateUserLocation = '%@'", userLocation);   

}

永远不会被调用。

【问题讨论】:

    标签: iphone mkmapview userlocation


    【解决方案1】:

    试试这个 Map.showsUserLocation=YES;

    【讨论】:

      【解决方案2】:

      参考资料提到这个委托方法从 iOS 4.0 开始可用。您的模拟器很可能运行的是 iOS 4.0,而您的手机运行的是 iOS 3.1。

      我遇到了同样的问题,仍在寻找解决方案。也许直接访问 CL 方法会有所帮助。

      【讨论】:

      • 谢谢!我从没想过要检查那个。
      • 我很高兴能帮上忙。我通过每秒左右查询用户位置来解决问题。如果您找到更好的解决方案,我将不胜感激您将其发布在这里 :)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-02
      • 1970-01-01
      • 1970-01-01
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      • 2015-01-31
      相关资源
      最近更新 更多