this one,thisおよびthis oneのように、stackOverflowでこれに関するいくつかの質問が見つかりました。最後に実際に働いたのですが、問題はをMapKit
で使用しています。これは(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
を意味します。MKMapViewの中心を移動して、デフォルトの位置アイコンが下部の中心に行くようにする方法
MKCoordinateRegion oldRegion = [mapView regionThatFits:MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 800.0f, 200.0f)];
CLLocationCoordinate2D centerPointOfOldRegion = oldRegion.center;
//Create a new center point (I added a quarter of oldRegion's latitudinal span)
CLLocationCoordinate2D centerPointOfNewRegion = CLLocationCoordinate2DMake(centerPointOfOldRegion.latitude + oldRegion.span.latitudeDelta/5.0, centerPointOfOldRegion.longitude);
//Create a new region with the new center point (same span as oldRegion)
MKCoordinateRegion newRegion = MKCoordinateRegionMake(centerPointOfNewRegion, oldRegion.span);
//Set the mapView's region
[_mapView setRegion:newRegion animated:NO];
私は自分の携帯電話を移動すると、それが成功したが更新され、accelometerはそれがnewRegionとoldRegionの間にけいれん効果を開始してアクセスされる:SOそれを今の問題は、私は、このソリューションを適用したとき。どのような提案?
UPDATE
私は私がuserLocation annotation
のデフォルトの画像を変更でき、これは私はこれがうまくいくかもしれないということや、その中心を設定する方法をここにそうmyAnnotaton.center
のように任意のアイデアを設定することができますプロパティを持っていました。この方法を見つけましたか?
- (MKAnnotationView *)mapView:(MKMapView *)mapView
viewForAnnotation:(id<MKAnnotation>)annotation {
if (annotation==(mapView.userLocation)) {
MKAnnotationView *myAnotation = [[MKAnnotationView alloc] init];
myAnotation.image = [UIImage imageNamed:@"marker"];
myAnotation.frame = CGRectMake(0, 0, 100, 100);
return myAnotation;
}
else
{
return nil;
}
}
、それに応じて回転する[_mapView setRegion:newRegionアニメーション:NO]を。それで、それは躍動的ではありません。 – sanman
@サンマンそれは働いていない...今は、アプリは、以前は自動的にズームしていたようにズームしている宿題がつまっています...今それは時間を突破し、クラッシュ...あなたが特定のコードの一部。 –