0

我有这个功能可以显示地图上大头针的坐标

-(void)newLocationSeleced:(CLLocation *) newLocation
{
_selectedLocation = CLLocationCoordinate2DMake(newLocation.coordinate.latitude, newLocation.coordinate.longitude);

NSLog(@"newLatitude: %f, newLongitude: %f", _selectedLocation.latitude, _selectedLocation.longitude);

}

调用此函数后,我可以看到新纬度具有正确的值以及新的经度

新纬度:42.448826,新经度:19.250086

但是,如果我尝试调用新函数(单击按钮后调用此函数),它只包含这行代码:

 NSLog(@"new latitude: %f, new longitude: %f", _selectedLocation.latitude, _selectedLocation.longitude);

我可以看到这个消息:

新纬度:0.000000,新经度:0.000000

它应该向我显示与调用第一个函数后显示的第一条消息相同的值。

在.h中我有这个

@property (nonatomic, readwrite)CLLocationCoordinate2D selectedLocation;
4

0 回答 0