使用selectannotation时,iOS Mapkit崩溃

时间:2012-06-21 12:41:33

标签: ios ipad crash mapkit sigsegv

我无法弄清楚这次崩溃的原因。

我在同一个屏幕上有一个带有MapView和Tableview的iPad应用程序。我试图让用户在表格中选择一行,然后在地图中突出显示相应的图钉,反之亦然。在模拟器中它工作正常。在设备上它工作了一段时间,但是如果我继续这样做,它将与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

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

我认为崩溃是因为一旦找到准确的位置就会出现当前的位置气泡。尝试使用以下

禁用用户位置
[self.mapView setShowsUserLocation:NO];

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

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

}

感谢。