【发布时间】:2011-02-12 16:27:44
【问题描述】:
我有一个使用顶部栏导航和 MapView 的应用程序。在地图视图上,我已经放置了一些注释,并在选择注释时,按下披露按钮进入SubView,然后使用我的应用程序崩溃的后退按钮回到MapView。它没有给我任何错误。
谁能帮我弄清楚为什么我的应用程序总是崩溃?
我做了一个简短的视频来展示这个神秘的崩溃(因为我怕我解释得不好)
视频可以在这个链接http://snuzzer.dk/pub/iPhoneAppMapKitCrash.mov看到
如果您需要查看任何代码以确定崩溃的原因,请告诉我。我不确定为此需要什么代码,因为我没有收到任何错误。
编辑:这是我的堆栈跟踪的输出:
#0 0x01275a63 in objc_msgSend
#1 0x0586c860 in ??
#2 0x0037ef1d in -[UINavigationController setDisappearingViewController:]
#3 0x0037c4f6 in -[UINavigationController _clearLastOperation]
#4 0x0037ce3f in -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
#5 0x00509e23 in -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:]
#6 0x0050afd2 in -[UINavigationTransitionView _cleanupTransition]
#7 0x002f6665 in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
#8 0x002f64f7 in -[UIViewAnimationState animationDidStop:finished:]
#9 0x01ffa6cb in run_animation_callbacks
#10 0x01ffa589 in CA::timer_callback
#11 0x010f4fe3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
#12 0x010f6594 in __CFRunLoopDoTimer
#13 0x01052cc9 in __CFRunLoopRun
#14 0x01052240 in CFRunLoopRunSpecific
#15 0x01052161 in CFRunLoopRunInMode
#16 0x01a48268 in GSEventRunModal
#17 0x01a4832d in GSEventRun
#18 0x002d442e in UIApplicationMain
#19 0x00002918 in main at main.m:14
编辑:似乎当我不释放我的 annotationViewController 时,应用程序不会崩溃。我将继续使用该应用程序,看看这是否正确。谁能告诉我这是否正确,如果正确,为什么?那我什么时候发布呢?
- (void)mapView:(MKMapView *)aMapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
for(MyAnnotation* a in mapView.annotations) { // searching for chosen annotation
if(view.annotation == a) {
// set array from plist
NSString *path = [[NSBundle mainBundle] pathForResource:@"Annotations" ofType:@"plist"];
NSMutableArray* anns = [[NSMutableArray alloc] initWithContentsOfFile:path];
AnnotationDetailViewController *annotationDetailViewController = [[AnnotationDetailViewController alloc] initWithNibName:@"AnnotationDetailViewController" bundle:nil];
annotationDetailViewController.ann = [anns objectAtIndex:[a.annId intValue]];
[self.navigationController pushViewController:annotationDetailViewController animated:YES];
[annotationDetailViewController release]; // this is the one that I think will correct the error
[anns release];
}
}
}
【问题讨论】:
-
您应该首先检查崩溃时的堆栈跟踪,如果它不能解释问题,请发布。
-
您很可能过度释放了一些对象,如果不检查您的代码就无法判断...我建议检查堆栈跟踪并检查您在哪里崩溃,就像@Rob Napier 说的那样,它可能是一个调用在你过度释放的物体上......如果你无法弄清楚,至少发布跟踪
-
@Rop Napier 和@Daniel,感谢您的意见。我无法通过堆栈跟踪找出崩溃的位置和原因。只是它似乎是在转变视图的变化。我已经更新了原始帖子以显示堆栈跟踪。你能看一下吗?
-
似乎当我不释放我的 annotationDetailViewController (当点击披露按钮时更改视图的 ViewController)时,我无法重现该错误。谁能告诉我为什么会这样?代码见原帖。
标签: iphone crash controller navigation mapkit