0

我正在使用 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
4

1 回答 1

0

现在解决了。我的第一个错误是我没有设置 map.delegate=self。第二个错误是我的互联网连接无法正常工作,这是我通过实现 mapViewDidFailLoadingMap:withError 方法得出的。谢谢... D-eptdeveloper

于 2013-10-22T05:08:05.210 回答