0

I've been adding MapView into my ViewController. Code as below:

MapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
MKCoordinateRegion region;
region.center.latitude = [[myStore.Location objectAtIndex:0] doubleValue];
region.center.longitude = [[myStore.Location objectAtIndex:1] doubleValue];
MKCoordinateSpan span;
span.latitudeDelta  = .0015;
span.longitudeDelta = .0015;
region.span = span;
[MapView setRegion:region animated:YES];

myStore.Location is an array with coordinates. XCode just crashes the app and return the error at [MapView setRegion:region animated:YES]; which i assume that it cannot init the mapview, can anyone help?

4

1 回答 1

2

我已经解决了我的问题......纬度和经度被颠倒了。[myStore.Location objectAtIndex:0]应该是经度,[myStore.Location objectAtIndex:1]应该是纬度......我很傻。

于 2012-07-08T02:29:19.530 回答