gpt4 book ai didi

iphone - 当我使用 popviewcontroller 时 MKMapView 崩溃

转载 作者:行者123 更新时间:2023-11-29 13:41:51 25 4
gpt4 key购买 nike

我的申请有问题。

最佳答案

您需要在-viewDidUnload: 中将 map View 的delegate 属性设置为nil。发生此崩溃是因为 map View 试图向它的委托(delegate)(您的 View Controller )发送消息,但一旦从堆栈中弹出,它就已被释放。

Apple 甚至在 MKMapViewDelegate Protocol Reference 中提到了这一点.

Before releasing an MKMapView object for which you have set a delegate, remember to set that object’s delegate property to nil. One place you can do this is in the -dealloc method where you dispose of the map view.

他们建议在 -dealloc 中取消 delegate,但是由于 ARC,-viewDidUnload 是前进的最佳选择。

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

关于iphone - 当我使用 popviewcontroller 时 MKMapView 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8873023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com