Crash when loading MKMapView

2019-03-16 00:11发布

问题:

I am having a peculiar crash when loading MKMapView. The pattern of occurrence is when I open ABPeoplePickerNavigationController in one view, which in turn triggers the UINavigationController delegate method

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.

No other views are having any problem. Only the view which loads MKMapView crashes with the following log

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

I have commented the part in the code which loads the mapview and then it works fine. So it seems that my navigation bar is deallocated somewhere, when the mapview loads. But what I cant understand is that, no other view in the app has any problem, only the one with mapview crashes. 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.

I tried profiling to analyze my problem. Here is what I found, but its not much helpful.

回答1:

I have had the same problem.

It's a leak issue on the 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 :)



回答2:

Did you mention correct protocol and delegate method and make sure you have correct Outlet with each object you have made.

hope this will work