2017-05-25 44 views
-1

地圖方向以此代碼形式工作。但是羅盤圖像不會像地圖旋轉那樣旋轉。請幫助如何使羅盤在這裏映射指南針圖像在此處旋轉地圖

- (void)mapView:(NMAMapView *)mapView didReceiveRotation:(float)rotation atLocation:(CGPoint)location 
{ 
[self.mapView setOrientation:180 withAnimation:NMAMapAnimationLinear]; 
_comPassImg.transform =CGAffineTransformMakeRotation(rotation);//not working smoothly 
} 

enter image description here

回答

0

你可以聽NMAMapView::NMAMapEvent::NMAMapEventOrientationChanged代替,例如:

[mapView respondToEvents:NMAMapEventOrientationChanged withBlock:^BOOL (NMAMapEvent event, NMAMapView *mapView, id eventData) { 
    _comPassImg.transform = CGAffineTransformMakeRotation(mapView.orientation); 
    return YES; 
}]; 

您也可以嘗試NMAOrientableMapMarker,看看是否適合你。

+0

其工作完美,但指南針的速度非常快。請幫忙。 –

+0

您可以使用'UIViewAnimation'參見https://stackoverflow.com/a/19585043/275524或https://stackoverflow.com/a/19585043/275524 – AndrewJC