简体   繁体   English

加载MKMapView时崩溃

[英]Crash when loading MKMapView

I am having a peculiar crash when loading MKMapView . 加载MKMapView时发生MKMapView崩溃。 The pattern of occurrence is when I open ABPeoplePickerNavigationController in one view, which in turn triggers the UINavigationController delegate method 发生的模式是当我在一个视图中打开ABPeoplePickerNavigationController时,这又触发了UINavigationController委托方法。

And after saving/without saving I move to another view--its working fine. 保存/不保存后,我转到另一个视图-可以正常工作。 Next view--its working fine. 下一个视图-工作正常。 But when I enter the view with MKMapView , it crashes. 但是,当我使用MKMapView进入视图时,它崩溃了。

No other views are having any problem. 没有其他观点有任何问题。 Only the view which loads MKMapView crashes with the following log 只有加载MKMapView的视图MKMapView崩溃,并显示以下日志

*** -[UINavigationBar barStyle]: message sent to deallocated instance

I have commented the part in the code which loads the mapview and then it works fine. 我已经在代码中注释了加载mapview的部分,然后工作正常。 So it seems that my navigation bar is deallocated somewhere, when the mapview loads. 因此,似乎在加载mapview时,我的导航栏被释放了。 But what I cant understand is that, no other view in the app has any problem, only the one with mapview crashes. 但是我无法理解的是,应用程序中的其他视图没有任何问题,只有带有mapview的视图崩溃了。 I have tried different patterns of testing and made sure that none of the other views are having any problems. 我尝试了不同的测试模式,并确保其他所有视图都没有问题。

The app doesn't crash in simulator. 该应用程序不会在模拟器中崩溃。 It crashes only on device. 它仅在设备上崩溃。 Why is this issue only in the view which loads mapview and in no other views. 为什么仅在加载mapview的视图中而不在其他视图中出现此问题?

I tried profiling to analyze my problem. 我尝试进行分析以分析我的问题。 Here is what I found, but its not much helpful. 这是我发现的,但没有太大帮助。

简介->僵尸

I have had the same problem. 我曾经也有过一样的问题。

It's a leak issue on the ABPeoplePickerNavigationController. 这是ABPeoplePickerNavigationController上的泄漏问题。 You have to ensure it won't be deallocated. 您必须确保它不会被释放。

I'm declaring it as a strong property to ensure it won't be deallocated and it works fine :) 我声明它是一个强大的属性,以确保它不会被释放,并且可以正常工作:)

Well, there is also a bit more simple solution to this. 嗯,对此还有一个更简单的解决方案。 The actual problem is in using ABPeoplePickerNavigationController as a singleton object, setting its delegate to a view controller and then dismissing the view controller. 实际的问题是使用ABPeoplePickerNavigationController作为单例对象,将其委托设置为视图控制器,然后关闭视图控制器。 So, in my case the solution that worked is this one: 因此,在我的情况下,有效的解决方案是:

  • (void)peoplePickerNavigationControllerDidCancel: (ABPeoplePickerNavigationController *)peoplePicker { peoplePicker.peoplePickerDelegate = nil; (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {peoplePicker.peoplePickerDelegate = nil; // clear delegate prior to dismissing self [self.navigationController dismissViewControllerAnimated:YES completion:nil]; //在解雇自己之前清除委托[self.navigationController dismissViewControllerAnimated:YEScomplete:nil]; } }

  • (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier { [self displayPerson:person]; (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker应该继续进行SelectingPerson:(ABRecordRef)person属性:(ABPropertyID)属性标识符:(ABMultiValueIdentifier)identifier {[self displayPerson:person]; peoplePicker.peoplePickerDelegate = nil; peoplePicker.peoplePickerDelegate = nil; // clear delegate prior to dismissing self [self.navigationController dismissViewControllerAnimated:YES completion:nil]; //在解雇自己之前清除委托[self.navigationController dismissViewControllerAnimated:YEScomplete:nil]; return NO; 返回否; } }

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

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