【问题标题】:iOS Mapkit crash when using selectannotation使用 selectannotation 时 iOS Mapkit 崩溃
【发布时间】:2012-06-23 16:51:03
【问题描述】:

我无法确定这次崩溃的原因。

我有一个 iPad 应用程序,在同一个屏幕上有一个 MapView 和 Tableview。我试图让用户在表格中选择一行,然后在地图中突出显示相应的引脚,反之亦然。在模拟器中它工作正常。在设备上它可以工作一段时间,但如果我继续这样做,它会因 SIGSEGV 而崩溃。我不知道为什么。

似乎只有从选定的 tableview 行转到在 mapview 中选择 pin 时才会发生。

这里是代码

  Place *p = [self.results objectAtIndex:[indexPath row]];

NSArray *annon = [self.mapView annotations];
for ( int i = 0; i < [annon count]; i++)
{
      NSObject *a = [annon objectAtIndex:i];
      if ([a isKindOfClass:PlaceAnnotation.class])
      {
           PlaceAnnotation *pa = (PlaceAnnotation *)a;
           if (p.placeid == pa.placeid)
           {  
                [self.mapView selectAnnotation:pa animated:YES];
                break;
           }
      }
}

这是执行此代码后我们看到的崩溃类型。

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x9
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                     0x317c4f78 0x317c1000 + 16248
1   CoreFoundation                      0x3195576b 0x318c6000 + 587627
2   CoreFoundation                      0x318cd644 0x318c6000 + 30276
3   CoreFoundation                      0x318cf701 0x318c6000 + 38657
4   MapKit                              0x36b061f3 0x36ab9000 + 315891
5   MapKit                              0x36acf33d 0x36ab9000 + 90941
6   MapKit                              0x36acf2f1 0x36ab9000 + 90865
7   MapKit                              0x36ad29bd 0x36ab9000 + 104893
8   MapKit                              0x36acdf03 0x36ab9000 + 85763

任何帮助将不胜感激。

【问题讨论】:

  • 你能弄明白吗?我想我遇到了类似的问题。

标签: ios ipad crash mapkit segmentation-fault


【解决方案1】:

我认为崩溃是因为找到准确位置后立即出现的当前位置气泡。尝试使用以下方法禁用用户位置

[self.mapView setShowsUserLocation:NO];

如果您需要用户位置,请包含以下委托方法并检查应用是否崩溃。

- (MKAnnotationView *) mapView:(MKMapView *) mapView viewForAnnotation:(id ) annotation {
if(![annotation isKindOfClass:[PlaceAnnotation class]]) {
    return nil;
}

}

谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-18
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多