MKMapView still sending messages to delegate after it's superview has been de-alloc'ed

前端 未结 2 2022
臣服心动
臣服心动 2021-02-19 07:52

EDIT: changed the title. I didn\'t know it at the time but this is a duplicate of Why am I crashing after MKMapView is freed if I'm no longer using it?


This q

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-19 08:35

    While it's true that the delegates for such classes should be explicitly set to nil, doing it in dealloc is already too late. You already lost your reference to the mapview during viewDidUnload. You should do the self.mapView.delegate = nil BEFORE viewDidUnload (so probably viewWillDisappear or viewDidDisappear)

    From my experience, only MKMapView and UIWebView behave this way.

提交回复
热议问题