“EXC_BAD_ACCESS” when switch too fast between an tableView and a mapView

时光总嘲笑我的痴心妄想 提交于 2019-12-02 11:19:44

Have you removed yourself as delegate of the mapview?

self.mapview.delegate = nil;

try removing it at viewWilldisappear or whenever you consider necessary as you might need it later if you have pushed a view controller and will return to the view later.

In a nutshell, remove it when your view cannot respond to the delegate which is why you got the EXC_BAD_ACCSS. it sent a message to your view but it was already released from memory.

Do you release and set to nil all your IBOutlets in the viewDidUnload? So at least you should do:

- (void)viewDidUnload {
   self.mapView = nil;
   [super viewDidUnload];
}

Generally in ViewDidUnload you should release and set to nil, any view objects that are created from a Nib file or allocated in your ViewDidLoad method

I would suggest to check whether self.whereAmIAnnotation isnt already released by at the time you add it to mapView. That might be one reason for the BAD_ACCESS you receive.

I had similar problem and my solution was to remove all overlays from the map before popping controller from UINavigationController. I was using OpenStreetMap.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!