【发布时间】:2011-12-06 03:22:28
【问题描述】:
我在 MapView 中遇到错误,我无法识别并且找不到相关文档。它看起来像这样:
CoreAnimation: ignoring exception:
Invalid Region <center:-180.00000000, -180.00000000
span:+2.81462803, +28.12500000>
显然,这些数字现在是我的代码独有的,但我不知道发生了什么。 MapView 运行得很好,我的所有注释都会显示出来(它会像我设置的那样放大用户的位置)。这具体指的是什么?
谢谢。
这是我用来缩放到用户位置的方法。这有点不正统,但这是我得到帮助的原因,因为由于各种原因我在缩放方面遇到问题(如果需要,我可以解释,但可能不相关):
- (void)zoomToUserLocation:(MKUserLocation *)userlocation
{
if (!userlocation)
return;
MKCoordinateRegion region;
region.center = userlocation.coordinate;
region.span = MKCoordinateSpanMake(2.0, 2.0);
region = [self.mapView regionThatFits:region];
[self.mapView setRegion:region animated:YES];
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self zoomToUserLocation:self.mapView.userLocation];
}
- (void)mapView:(MKMapView *)theMapView didUpdateUserLocation:(MKUserLocation *)location
{
[self zoomToUserLocation:location];
}
【问题讨论】:
-
中心坐标-180,-180无效。在某处,代码错误地设置了 region.center(尽管在这种情况下它通常会崩溃)。
-
region.center = userlocation.coordinate 在我用来缩放到用户位置的方法中。 'userlocation' 在方法中被设置为 MKUserLocation,所以它似乎没有意义......
-
能否将方法代码添加到问题中?
标签: ios xcode core-animation android-mapview