导航和MapKit使应用程序崩溃 [英] Navigation and MapKit makes app crash

查看:159
本文介绍了导航和MapKit使应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序使用顶部栏导航和一个MapView。在地图视图上,我放置了一些注释,当选择一个注释,按揭露按钮进入一个子视图,然后返回到MapView使用后退按钮我的应用程序崩溃。它不会给我任何错误。



任何人都可以帮助我找出为什么我的应用程序不断崩溃?



我做了一个短视频显示这个神秘的崩溃(因为我恐怕我不解释它很好)



视频可以在此链接上看到 http://snuzzer.dk/pub/iPhoneAppMapKitCrash.mov



请告诉我,如果你需要查看任何代码,以确定崩溃的原因。我不知道什么代码是必要的,因为我没有得到任何错误。



编辑:这是我的堆栈trace:

 #0 0x01275a63 in objc_msgSend 
#1 0x0586c860 in?
#2 0x0037ef1d中 - [UINavigationController的setDisappearingViewController:]
#3 0x0037c4f6中 - [UINavigationController的_clearLastOperation]
#4 0x0037ce3f中 - [UINavigationController的navigationTransitionView:didEndTransition:fromView:toView:]
在#5 0x00509e23 - [UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:]
#6 0x0050afd2在 - [UINavigationTransitionView _cleanupTransition]
#7 0x002f6665在 - [UIViewAnimationState sendDelegateAnimationDidStop:完成:]
#8 0x002f64f7在 - [ UIViewAnimationState animationDidStop:完成:]
#9 0x01ffa6cb在run_animation_callbacks
在CA :: timer_callback
## 10 11 0x01ffa589在0x010f4fe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
#12 0x010f6594在__CFRunLoopDoTimer
# 13 0x01052cc9在__CFRunLoopRun
#在CFRunLoopRunSpecific
#14 0x01052240 15 0x01052161在CFRunLoopRunInMode
#16 0x01a48268在GSEventRunModal
#17 0x01a4832d在GSEventRun
#18 0x002d442e在UIApplicationMain
#19 0x00002918 in main.m:14

强>似乎当我不释放我的annotationViewController应用程序不会崩溃。我会继续玩应用程序,看看这是否正确。任何人都可以告诉我这是否正确,如果是这样,为什么?

   - (void)mapView:(MKMapView *)aMapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *){控制
为(MyAnnotation *一个在mapView.annotations){//搜索选择注释
如果(view.annotation ==一){
//集array from plist
NSString * path = [[NSBundle mainBundle] pathForResource:@AnnotationsofType:@plist];
NSMutableArray * anns = [[NSMutableArray alloc] initWithContentsOfFile:path];

AnnotationDetailViewController * annotationDetailViewController = [[AnnotationDetailViewController alloc] initWithNibName:@AnnotationDetailViewControllerbundle:nil];
annotationDetailViewController.ann = [anns objectAtIndex:[a.annId intValue]];

[self.navigationController pushViewController:annotationDetailViewController animated:YES];
[annotationDetailViewController release]; //这是一个我认为会纠正错误
[anns release];
}
}
}


解决方案>

您应该在 AnnotationDetailViewController 中查找一个ivar,以确定您是保留/过量发布。我怀疑一些UIView,也许是一个IBOutlet,你没有配置保留,特别是如果你也没有设置为nil在 viewDidUnload 。我建议您阅读 Nib对象的内存管理如果你还没有。



如果没有代码,或者更多的变量信息,很难调试,但这是我会看到,崩溃。


I have an application which used top bar navigation and a MapView. On the map view I have placed some annotations and when selecting an annotation, pressing the disclosure button to go into a subview and then going back to the MapView using the back button my application crashes. It does not give me any errors.

Can anyone help me figure out why my application keeps crashing?

I have made a short video showing this mysterious crash (because I'm afraid that I do not explain it very well)

The video can be seen on this link http://snuzzer.dk/pub/iPhoneAppMapKitCrash.mov

Please tell me if you need to see any code in order to determine the reason for the crash. I am not sure what code would be necessary for this as I do not get any error.

EDIT: This is the output of my stack trace:

#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

EDIT: It seems that when I do not release my annotationViewController the application does not crash. I will keep playing with the application to see if this is right. Can anyone tell me if this might be right and if so, why? And when would I release it then?

 - (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];
        }
    }
}

解决方案

You should look for an ivar in AnnotationDetailViewController that you are under-retaining/over-releasing. I would suspect some UIView, perhaps an IBOutlet that you did not configure to retain, particularly if you also fail to set it to nil in viewDidUnload. I recommend you read Memory Management of Nib Objects if you haven't already.

It's difficult to debug this without the code, or more information about your variables, but that's where I would look given where it's crashing.

这篇关于导航和MapKit使应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆