【发布时间】:2014-01-21 09:41:01
【问题描述】:
我正在尝试获取 CLLocation 属性来存储位置 MKMapView。我的这部分代码:
在我的 .h 上
@property (retain, nonatomic) CLLocation *currentlocation;
在我的.m上
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
if ((_currentlocation.coordinate.longitude == 0 ) && (_currentlocation.coordinate.latitude == 0) )
{
self.currentlocation = [self.mapView.userLocation.location copy];
}
问题是每次尝试更新“self.currentlocation”为0的位置。我的问题是如何保留self.currentlocation的值?
非常感谢您的帮助。
【问题讨论】:
-
self.currentlocation = ...行真的在执行吗?像这样比较浮点值是不可靠的。相反,检查 _currentLocation 是否为零。这就是 David P 所说的(if条件不起作用)。
标签: ios iphone cllocation