Ios MapView崩溃

Ios MapView崩溃,ios,mkmapview,Ios,Mkmapview,我一直在将MapView添加到我的ViewController中。代码如下: MapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; MKCoordinateRegion region; region.center.latitude = [[myStore.Location objectAtIndex:0] doubleValue]; region.center.longitude = [[myStore.L

我一直在将MapView添加到我的ViewController中。代码如下:

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
是一个带有坐标的数组。XCode只是使应用程序崩溃,并在
[MapView setRegion:region animated:YES]返回错误我假设它无法初始化mapview,有人能帮忙吗

我已经解决了我的问题。。。纬度和经度正在倒转
[myStore.Location objectAtIndex:0]
应该是经度,
[myStore.Location objectAtIndex:1]
应该是纬度。。。愚蠢的我。

尝试从崩溃日志中获取更多数据。添加异常断点以帮助您。尝试在MKMapView的alloc和init之后添加一个断点,以查看它是否已初始化。由于该崩溃,您在调试器中究竟看到了什么?setRegion上的崩溃通常意味着该区域无效。记录您从myStore获得的值,并将其放入区域中心。您应该将您的答案标记为已接受。这将有助于您和堆栈溢出社区。阅读本文了解更多详细信息:还可以在问题中添加崩溃日志/错误详细信息。这将帮助将来的其他人确切地知道你的问题到底是什么,而你自己已经回答了!