私はxcode 4.3.3を使用しています。
サンプルのマップビュー アプリを試しています。これには、1つのマップビューを持つ1つのビューコントローラーがあります。コードで座標を設定した特定の場所を表示したい。地域を設定せずに実行すると、マップにはデフォルトのアメリカ地域が表示されますが、地域を座標で設定すると、灰色のタイルのみが表示され、何も表示されません。以下は私のコードです。
#import "BranchViewController.h"
#import <MapKit/MapKit.h>
#import "Annotation.h"
@interface BranchViewController ()
@end
#define CBB_LATITUDE 26.2167;
#define CBB_LONGITUDE 50.5833;
#define THE_SPAN 0.01f;
@implementation BranchViewController
@synthesize myMapView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
NSLog(@"BranchViewController - viewDidLoad()");
[super viewDidLoad];
// Do any additional setup after loading the view.
// CBB REGION
MKCoordinateRegion cbbRegion;
// CBB LATITUDE N LONGITUDE
CLLocationCoordinate2D center;
center.latitude = CBB_LATITUDE;
center.longitude = CBB_LONGITUDE;
// CBB SPAN
MKCoordinateSpan span;
span.latitudeDelta = THE_SPAN;
span.longitudeDelta = THE_SPAN;
cbbRegion.center = center;
cbbRegion.span = span;
// SETTING MAPVIEW
[self.myMapView setRegion:cbbRegion animated:NO];
[self.myMapView setMapType:MKMapTypeStandard];
//[self.myMapView setZoomEnabled:YES];
self.myMapView.showsUserLocation = YES;
}
- (void)viewDidUnload
{
[self setMyMapView:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end