RootViewController.mにタブがあります。タブには2つのボタンがあります。クリックすると最初のボタンが、mapViewが表示されているCorpViewcontrollerに移動します。最初の試行で最初のボタンをクリックすると、マップは空白になり、下部にgoogleラベルが表示されます。戻るをクリックしてからもう一度ボタンをクリックすると、地図が表示されます。最初のボタンクリックで常に地図を表示することは可能ですか?
私のrootViewController.mは2番目の画面に移動します:
[self.navigationController pushViewController:self.corpController animated:YES];
corpViewControllerと呼ばれる2番目の画面には、次のコードがあります。
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Set Remote Location";
self.jsonData = [[NSMutableData alloc] init];
mapView.showsUserLocation = YES;
//Setup the double tap gesture for getting the remote location..
UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleGesture:)];
tgr.numberOfTapsRequired = 2;
tgr.numberOfTouchesRequired = 1;
[mapView addGestureRecognizer:tgr];
mapView.delegate = self;
NSLog(@"viewDidLoad done");
}
- (void)viewWillAppear:(BOOL)animated {
NSLog(@"viewWillAppear");
appDelegate = (NBSAppDelegate *)[[UIApplication sharedApplication] delegate];
double curLat = [appDelegate.curLat doubleValue];
MKUserLocation *userLocation = mapView.userLocation;
double miles = 10.0;
double scalingFactor = ABS( (cos(2 * M_PI * curLat / 360.0) ));
MKCoordinateSpan span;
span.latitudeDelta = miles/69.0;
span.longitudeDelta = miles/(scalingFactor * 69.0);
MKCoordinateRegion region2;
region2.span = span;
region2.center = userLocation.coordinate;
[mapView setRegion:region2 animated:YES];
NSLog(@"viewWillAppear done..");
}
お知らせ下さい。
ありがとうございました