Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios MapKit打开时聚焦于错误的位置_Ios_Mapkit - Fatal编程技术网

Ios MapKit打开时聚焦于错误的位置

Ios MapKit打开时聚焦于错误的位置,ios,mapkit,Ios,Mapkit,我有以下问题:我的地图工具包中有一个地址,但是当我第一次打开地图时,它并没有到达预定义的位置。但是,它在第二次打开时确实会这样做。这是我的代码中的问题吗?我在模拟器中没有这个问题,但在手机上测试时会出现。还有其他人谈到这个问题吗 抱歉,如果这是太多的代码。谢谢 #import "MapViewController.h" #import "Annotation.h" @interface MapViewController () @end //EDINBURGH Kilt Store Coo

我有以下问题:我的地图工具包中有一个地址,但是当我第一次打开地图时,它并没有到达预定义的位置。但是,它在第二次打开时确实会这样做。这是我的代码中的问题吗?我在模拟器中没有这个问题,但在手机上测试时会出现。还有其他人谈到这个问题吗

抱歉,如果这是太多的代码。谢谢

#import "MapViewController.h"
#import "Annotation.h"

@interface MapViewController ()

@end

//EDINBURGH Kilt Store Coordinates
#define EDI_LATITUDE 55.945984;
#define EDI_LONGITUDE -3.220979;

//MUSSELBURGH Kilt Store Coordinates
#define MUSS_LATITUDE 55.943748;
#define MUSS_LONGITUDE -3.058187;

//DALKEITH Kilt Store Coordinates
#define DAL_LATITUDE 55.883271;
#define DAL_LONGITUDE -3.083474;

//DUNDEE Kilt Store Coordinates
#define DUN_LATITUDE 56.459118;
#define DUN_LONGITUDE -2.97124;

//Span
#define THE_SPAN 0.10f;


@implementation MapViewController
@synthesize myMapView;

- (void)viewDidLoad
{
    [super viewDidLoad];
    //Create the region
    MKCoordinateRegion myRegion;

    //Center
    CLLocationCoordinate2D center;
    center.latitude = EDI_LATITUDE;
    center.longitude = EDI_LONGITUDE;

    //Span
    MKCoordinateSpan span;
    span.latitudeDelta = THE_SPAN;
    span.longitudeDelta = THE_SPAN;

    myRegion.center = center;
    myRegion.span = span;

    //Set our mapView
    [myMapView setRegion:myRegion animated:YES];

    //Annotation
    NSMutableArray * locations = [[NSMutableArray alloc] init];
    CLLocationCoordinate2D location;
    Annotation * myAnn;

    //Edinburgh Annotation
    myAnn = [[Annotation alloc] init];
    location.latitude = EDI_LATITUDE;
    location.longitude = EDI_LONGITUDE;
    myAnn.coordinate = location;
    myAnn.title = @"The Kilt Store";
    myAnn.subtitle= @"Haymarket";
    [locations addObject:myAnn];

    //Musselburgh Annotation
    myAnn = [[Annotation alloc] init];
    location.latitude = MUSS_LATITUDE;
    location.longitude = MUSS_LONGITUDE;
    myAnn.coordinate = location;
    myAnn.title = @"The Kilt Store";
    myAnn.subtitle= @"Musselburgh";
    [locations addObject:myAnn];

    //Musselburgh Annotation
    myAnn = [[Annotation alloc] init];
    location.latitude = DAL_LATITUDE;
    location.longitude = DAL_LONGITUDE;
    myAnn.coordinate = location;
    myAnn.title = @"The Kilt Store";
    myAnn.subtitle= @"Dalkeith";
    [locations addObject:myAnn];

    //Dundee Annotation
    myAnn = [[Annotation alloc] init];
    location.latitude = DUN_LATITUDE;
    location.longitude = DUN_LONGITUDE;
    myAnn.coordinate = location;
    myAnn.title = @"The Kilt Store";
    myAnn.subtitle= @"Dundee";
    [locations addObject:myAnn];

     [self.myMapView addAnnotations:locations];
}

- (void)viewDidUnload
{
    [self setMyMapView:nil];
    [super viewDidUnload];
    //Release any retained subview
}

@end