我正在使用xcode 4.3.3。
我正在尝试一个示例mapview应用。其中我只有1个视图控制器和1个mapview。我想显示一个特定的位置,我在我的代码中设置了coordiates。当我在没有设置区域的情况下运行时,我的地图显示默认的美国区域,但是当我使用坐标设置我的区域时,它只显示灰色瓷砖而不显示任以下是我的代码。
#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
答案 0 :(得分:0)
现在已经解决了。我的第一个错误是我没有设置map.delegate = self。第二个错误是我的互联网连接不起作用,我想通过实现mapViewDidFailLoadingMap:withError方法。谢谢... D-eptdeveloper