我正在开发一个iphone应用程序,在该应用程序中我将在MKMapView上的不同位置显示客户端停车位置。现在我需要在MKMapView中使用罗盘模式来显示特定方向(SE,SW,NE,NW)的客户停车位,为此我运行以下代码。
-(void)updateHeading:(CLHeading *) newHeading
{
NSLog(@"New magnetic heading: %f", newHeading.magneticHeading);
NSLog(@"New true heading: %f", newHeading.trueHeading);
double rotation = newHeading.magneticHeading * 3.14159/-180;
[mapView setTransform:CGAffineTransformMakeRotation(-rotation)];
[[mapView annotations] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
{
MKAnnotationView * view = [mapView viewForAnnotation:obj];
[view setTransform:CGAffineTransformMakeRotation(rotation)];
}];
}
Everthing在MKMapView中运行正常,但我的MKMapView以相反的顺序显示,当设备开始旋转时,我在ios5和ios6中也遇到了这个问题。 注意:当我在美国测试这个应用程序时,地图显示正确,而我在我的位置测试应用程序(印度)地图变为反向。
`
提前感谢您的帮助。
答案 0 :(得分:1)
在旋转时,地图是否打算以用户为中心?如果是这样,你可以将MKMapView的userTrackingMode设置为MKUserTrackingModeFollowWithHeading。
如果没有,那么如果告诉我们你在MagneticHeading中看到了什么,在事情正确和出错时告诉我们真正的行动和轮换。