5
我想要獲得它,以便在旋轉iOS 7地圖時註釋隨相機標題一起旋轉。想象一下,我有任何時候都必須指向北方的針註釋。在iOS 7地圖相機旋轉上更新地圖註釋
這看起來很簡單,首先,應該有一個MKMapViewDelegate用於獲取相機旋轉,但沒有。
- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
我使用志願也試過:
我使用地圖代表們然後查詢地圖視圖的camera.heading
對象,但首先這些代表似乎只是之前和旋轉手勢之後,曾經一度被稱爲嘗試在camera.heading對象上,但這不起作用,並且相機對象似乎是某種只在旋轉手勢完成時才更新的代理對象。
到目前爲止,我最成功的方法是添加一個旋轉手勢識別器來計算旋轉增量,並將其與區域更改代表開始時報告的攝像頭標題一起使用。這很有用,但在OS 7中,您可以「輕拂」您的旋轉手勢,並增加了我無法跟蹤的速度。有沒有辦法實時追蹤攝像頭的方向?
- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated
{
heading = self.mapView.camera.heading;
}
- (void)rotationHandler:(UIRotationGestureRecognizer *)gesture
{
if(gesture.state == UIGestureRecognizerStateChanged) {
CGFloat headingDelta = (gesture.rotation * (180.0/M_PI));
headingDelta = fmod(headingDelta, 360.0);
CGFloat newHeading = heading - headingDelta;
[self updateCompassesWithHeading:actualHeading];
}
}
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
[self updateCompassesWithHeading:self.mapView.camera.heading];
}
Thanks @Ross,似乎這是唯一的選擇。令人沮喪。我可能會提交一個錯誤報告。 – Electron