繁体   English   中英

导航和MapKit使应用程序崩溃

[英]Navigation and MapKit makes app crash

我有一个使用顶栏导航和MapView的应用程序。 在地图视图上,我放置了一些注释,选择注释时,按显示按钮进入子视图,然后使用后退按钮返回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

编辑:似乎当我不释放我的ationmentViewController时,应用程序不会崩溃。 我将继续使用该应用程序,以查看是否正确。 谁能告诉我这是否正确,如果正确,为什么? 那我什么时候发布呢?

 - (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时。 我建议您阅读Nib对象的内存管理(如果还没有的话)。

如果没有代码或没有更多有关变量的信息,则很难调试它,但这就是崩溃的地方。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM