Iphone mapkit addAnnotations崩溃
我有一个UITabBarController和一个“地图”选项卡。 “地图”选项卡与我的自定义UIViewController关联,上面有一个MKMapView。 当我当前选择另一个选项卡时,当我点击地图选项卡时,带iOS4.3.1的iPhone4会崩溃,崩溃日志如下:Iphone mapkit addAnnotations崩溃,iphone,objective-c,mapkit,Iphone,Objective C,Mapkit,我有一个UITabBarController和一个“地图”选项卡。 “地图”选项卡与我的自定义UIViewController关联,上面有一个MKMapView。 当我当前选择另一个选项卡时,当我点击地图选项卡时,带iOS4.3.1的iPhone4会崩溃,崩溃日志如下: - (CLLocationCoordinate2D)coordinate { CLLocationCoordinate2D coordinate_; coordinate_.latitude = [ self
- (CLLocationCoordinate2D)coordinate {
CLLocationCoordinate2D coordinate_;
coordinate_.latitude = [ self.lat doubleValue ];
coordinate_.longitude = [ self.lng doubleValue ];
return coordinate_;
}
我能做些什么来防止这次撞车?
我的代码怎么了
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** ];
}
我认为堆栈跟踪中的第五行是viewDidLoad,
所以崩溃一定是(我想…)由于我的注释。当它崩溃时,我有300-400条注释。
My annotations具有如下坐标访问器:
- (CLLocationCoordinate2D)coordinate {
CLLocationCoordinate2D coordinate_;
coordinate_.latitude = [ self.lat doubleValue ];
coordinate_.longitude = [ self.lng doubleValue ];
return coordinate_;
}
其中,自升式液化天然气定义为:
@property (nonatomic, retain) NSNumber* lat;
@property (nonatomic, retain) NSNumber* lng;
它已经是AppStore上的一个应用程序,我不知道如何重现崩溃,只是现在没有崩溃,所以我只有崩溃日志和源代码。
有什么建议吗
提前感谢。调用addAnnotations:后,注释数组会发生什么变化?也许在所有注释(你说你有几百个注释)都可以添加到视图之前就发布了它?是否“添加到视图”是异步的?有几个地方我调用
[self.mapView removeAnnotations:self.mapView.annotations];[self.mapView addAnnotations:*我的注释**]代码>那么这可能是另一个bug?(我写了另一篇,因为我自己发现了一个iOS错误),我会在这之后回答自己。。我发现添加带有的注释(lat它很可能是异步的,否则添加数百条注释会冻结应用程序。也许你的一些用户的注释比大多数用户多得多?尝试添加大量注释(比如500条)-也许你可以重现崩溃。调用addAnnotations后注释数组会发生什么情况:?也许它在所有注释(你说你有几百个)都可以添加到视图之前被释放?是否“添加到视图”是异步的?有几个地方我调用[self.mapView removeAnnotations:self.mapView.annotations];[self.mapView addAnnotations:*my annotations**];
这可能是另一个bug?(我写了另一个,因为我自己发现了一个iOS bug),之后我会自己回答。我发现用(lat)它很可能是异步的,否则添加数百条注释会冻结应用程序。也许您的一些用户的注释比大多数用户多得多?尝试添加大量注释(如500条)-也许您可以重现崩溃。