這裏是我如何旋轉的MapView(見Rotate MapView using Compass orientation):
[self.mapView setTransform:CGAffineTransformMakeRotation(-1 * currentHeading.magneticHeading * 3.14159/180)];
然後保持的註解視圖的方向與設備的頂部:
for (MKAnnotation *annotation in self.mapView.annotations) {
MKAnnotationView *annotationView = [self.mapView viewForAnnotation:annotation];
[annotationView setTransform:CGAffineTransformMakeRotation(currentHeading.magneticHeading * 3.14159/180)];
}
如果你希望annotationViews的旋轉點被稱爲底部中心,我相信你會設置每個視圖的anchorPoint如下:
annotationView.layer.anchorPoint = CGPointMake(0.5, 1.0);
我仍然有,當我做到這一點,但(可能是相同的問題計算器的問題:改變-MY-calayers-anchorpoint-移動-中,視圖)的annotationView位置改變的一些問題。
我正在做一個類似的事情根據CoreLocation retireived旋轉一個MapView。我在github的MIT下發布了它(還包括像BarButtonItem那樣更有用的東西,其行爲與內置的Google Maps App類似) - https://github.com/myell0w/MTLocation – myell0w 2011-03-06 13:59:29
我該如何聲明currentHeading? ? – 2011-05-29 11:46:49
嘗試在didUpdateHeading內部使用newHeading變量:(CLHeading *)newHeading handler – fyasar 2011-06-07 08:26:04