それは本当にばかげた質問であり、紛らわしいです。マップを特定の地域に広げて焦点を合わせようとしているので、場所を Userlocation として設定しました。完璧です。
ユーザーの場所を保存してviewDidLoadにアップロードしようとすると、機能しません。
- (IBAction)GetcurrentLocation1:(id)sender{
Maplocation.showsUserLocation=YES;
MKCoordinateRegion mapRegion;
mapRegion.center = Maplocation.userLocation.coordinate;
NSLog(@"The USer Location are :%f %f",Maplocation.userLocation.coordinate.latitude,Maplocation.userLocation.coordinate.longitude);
mapRegion.span.latitudeDelta = 0.2;
mapRegion.span.longitudeDelta = 0.2;
self.currentProduct.shop.longcoordinate=Maplocation.userLocation.coordinate.longitude;
self.currentProduct.shop.latcoordinate=Maplocation.userLocation.coordinate.latitude;
[Maplocation setRegion:mapRegion animated: YES];
}
-(void)showtheuseronmap:(double)longtitude:(double)latitude{
if(!annotation){
annotation =[[MyAnotation alloc]initWithCoordinate:CLLocationCoordinate2DMake(latitude, longtitude) title:[self.currentProduct.shop shopname] subtitle:@"The shop is here"];
}
[Maplocation addAnnotation:annotation];
MKCoordinateRegion mapRegion;
CLLocationCoordinate2D locationsh=CLLocationCoordinate2DMake(latitude, longtitude);
mapRegion.center=locationsh;
NSLog(@"The USer Location are :%f",mapRegion.center.latitude);
mapRegion.span.latitudeDelta= 0.2;
mapRegion.span.longitudeDelta= 0.2;
[Maplocation setRegion:mapRegion animated:YES];
//Maplocation.showsUserLocation=YES;
}
ビューでDidLoad
[self showtheuseronmap:self.currentProduct.shop.longcoordinate :self.currentProduct.shop.latcoordinate];
NSLog では、座標が正しく表示されます。
私は本当に混乱しています、私はこれがどのように起こるのか分かりませんか?