iphone - 导航和MapKit使应用程序崩溃

标签 iphone crash controller navigation mapkit

我有一个使用顶栏导航和MapView的应用程序。在 map View 上,我放置了一些注释,选择注释时,按显示按钮进入 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

编辑:看来,当我不释放我的CommentViewController时,应用程序不会崩溃。我将继续使用该应用程序,以查看是否正确。谁能告诉我这是否正确,如果正确,为什么?那我什么时候发布呢?
 - (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];
        }
    }
}

最佳答案

您应该在AnnotationDetailViewController中查找保留/释放不足的ivar。我会怀疑某些UIView,也许是您未配置为保留的IBOutlet,尤其是如果您也未能在viewDidUnload中将其设置为nil时。如果您尚未阅读Memory Management of Nib Objects,我建议您阅读。

没有代码或有关变量的更多信息,调试起来很困难,但这就是崩溃的地方。

关于iphone - 导航和MapKit使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4979143/

相关文章:

c# - 如何将对象数组从 Angular 前端传递到 C# 后端

iphone - 如何捕获 UITableView/UIScrollView 完整内容的 UIImage 并使其在 ios 设备上工作

ios - 使用适用于 iOS 的 Obj C 启动合并调用

iphone - 事件中无法播放声音(wav)

visual-studio - 自动创建 Visual C++ 故障转储

iphone-sdk-3.0 - 当我的UIViewController从IBAction访问AppDelegate中的NSArray时,程序崩溃

.net - 调试错误Appcrash Server 2008和Windows 7 C0000005 C0000096

ruby-on-rails - Rails 中模型的错误复数化

ios - 当应用程序被终止(非事件)时,点击 Firebase 通知不起作用

caching - 避免单例和全局变量——但是缓存、提供者、 Controller ……呢?