mapkit addAnnotations崩溃

时间:2011-04-16 15:18:30

标签: iphone objective-c mapkit

我有一个UITabBarController和一个“Map”标签。 Map选项卡与我的自定义UIViewController相关联,它上面有一个MKMapView。 当我正在选择另一个标签页时,当我点击“地图”标签时,带有iOS4.3.1的iPhone4会崩溃并显示崩溃日志:

我该怎么做才能防止这次崩溃? 我的代码出了什么问题?

  0   MapKit                        0x3501fc20 _contains(objc_object*, MKQuadTrieNode*) + 16
  1   MapKit                        0x3501fc00 -[MKQuadTrie contains:] + 12
  2   MapKit                        0x3501f9f2 -[MKAnnotationContainerView addAnnotation:] + 218
  3   MapKit                        0x3501f8e6 -[MKAnnotationContainerView addAnnotations:] + 102
  4   MapKit                        0x3501f856 -[MKMapView addAnnotations:] + 42

  5   MyApp                         0x000075d6 0x1000 + 26070

  6   UIKit                         0x3559ff08 -[UIViewController view] + 104
  7   UIKit                         0x355dd1d4 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 60
  8   UIKit                         0x355dd186 -[UITabBarController transitionFromViewController:toViewController:] + 26
  9   UIKit                         0x355dca2c -[UITabBarController _setSelectedViewController:] + 180
  10  UIKit                         0x35661ce4 -[UITabBarController setSelectedViewController:] + 8
  11  UIKit                         0x35661be0 -[UITabBarController _tabBarItemClicked:] + 220
  12  CoreFoundation                0x3593656a -[NSObject(NSObject) performSelector:withObject:withObject:] + 18
  13  UIKit                         0x35585ec2 -[UIApplication sendAction:to:from:forEvent:] + 78
  14  UIKit                         0x35585e62 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
  15  UIKit                         0x35661a84 -[UITabBar _sendAction:withEvent:] + 264
  16  CoreFoundation                0x3593656a -[NSObject(NSObject) performSelector:withObject:withObject:] + 18
  17  UIKit                         0x35585ec2 -[UIApplication sendAction:to:from:forEvent:] + 78
  18  UIKit                         0x35585e62 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
  19  UIKit                         0x35585e34 -[UIControl sendAction:to:forEvent:] + 32
  20  UIKit                         0x35585b86 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 350
  21  UIKit                         0x355bfbd2 -[UIControl sendActionsForControlEvents:] + 10
  22  UIKit                         0x3566180e -[UITabBar(Static) _buttonUp:] + 74
  23  CoreFoundation                0x3593656a -[NSObject(NSObject) performSelector:withObject:withObject:] + 18
  24  UIKit                         0x35585ec2 -[UIApplication sendAction:to:from:forEvent:] + 78
  25  UIKit                         0x35585e62 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
  26  UIKit                         0x35585e34 -[UIControl sendAction:to:forEvent:] + 32
  27  UIKit                         0x35585b86 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 350
  28  UIKit                         0x3558641c -[UIControl touchesEnded:withEvent:] + 336
  29  UIKit                         0x35584bee -[UIWindow _sendTouchesForEvent:] + 362
  30  UIKit                         0x35584568 -[UIWindow sendEvent:] + 256
  31  UIKit                         0x3556d30c -[UIApplication sendEvent:] + 292
  32  UIKit                         0x3556cc4c _UIApplicationHandleEvent + 5084

我的自定义UIViewController在viewDidLoad上执行此操作:

- (void) viewDidLoad {
    [super viewDidLoad];

    self.mapView.showsUserLocation = NO;

    // some [[NSNotificationCenter defaultCenter] addObserver....] snipped

    [ self.mapView addAnnotations: **my annotations** ];
}

我认为堆栈跟踪中的第5行是viewDidLoad, 所以由于我的注释,崩溃必须(我认为......)。当它崩溃时我有300-400个注释。 我的注释有一个像这样的坐标访问器:

- (CLLocationCoordinate2D)coordinate {
    CLLocationCoordinate2D  coordinate_;
    coordinate_.latitude  = [ self.lat doubleValue ];
    coordinate_.longitude = [ self.lng doubleValue ];
    return coordinate_;
}

其中self.lat,lng定义为:

@property (nonatomic, retain) NSNumber* lat;
@property (nonatomic, retain) NSNumber* lng;

这是AppStore上的应用程序,我不知道如何重现崩溃,它现在不会崩溃,所以我只有崩溃日志和我的源代码。 有什么建议吗?

提前致谢。

0 个答案:

没有答案