我正在开发一个 iPhone 应用程序,在该应用程序中我向客户端展示 MKMapView 上不同位置的 parking 位。现在我需要在 MKMapView 中使用指南针模式来显示特定方向(SE、SW、NE、NW)的客户端 parking 位,为此我运行以下代码。
-(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)];
}];
}
一切在 MKMapView 中工作正常,但我的 MKMapView 以相反的顺序显示,当设备开始旋转时,我在 ios5 和 ios6 中也面临这个问题。 注意:当我在美国测试此应用程序时, map 显示正确,而我在我所在的位置(印度)测试该应用程序时, map 会变成反向。
`
在此先感谢您的帮助。
最佳答案
map 在旋转时是否要以用户为中心?如果是这样,您可以将 MKMapView 的 userTrackingMode 设置为 MKUserTrackingModeFollowWithHeading。
如果没有,那么告诉我们您在 magicHeading、trueHeading 和旋转中看到的情况(当事情顺利和错误时)如何?
关于objective-c - 当在我的 iPhone 应用程序项目中使用指南针模式时,MKMapView 相反,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12873173/