MKMapView 处置
释放 MKMapView 后,我发生了奇怪的(?)崩溃。 MKMapView 是我的视图控制器中的子视图,在我从导航堆栈中删除该视图并释放它后,应用程序会因该堆栈而崩溃:
...
#4 0x34196dc8 in -[MKMapView(UserPositioningInternal) locationManagerFailedToUpdateLocation:withError:]
#5 0x3417030c in -[MKLocationManager _reportLocationFailureWithError:]
#6 0x3416de94 in -[MKLocationManager locationManager:didFailWithError:]
#7 0x3205f538 in -[CLLocationManager onClientEventLocation:]
#8 0x3205dd5c in -[CLLocationManager onClientEvent:supportInfo:]
...
处置我的视图时是否必须执行一些额外的步骤?
编辑:在控制器的 dealloc 方法中将 mapView.showsUserLocation 设置为 NO 似乎有帮助。问题仍然是——这是有意的行为吗?
I have a strange(?) crash after releasing MKMapView. MKMapView is a subview in my view controller and after I remove that view from navigation stack and release it application crashes with this stack:
...
#4 0x34196dc8 in -[MKMapView(UserPositioningInternal) locationManagerFailedToUpdateLocation:withError:]
#5 0x3417030c in -[MKLocationManager _reportLocationFailureWithError:]
#6 0x3416de94 in -[MKLocationManager locationManager:didFailWithError:]
#7 0x3205f538 in -[CLLocationManager onClientEventLocation:]
#8 0x3205dd5c in -[CLLocationManager onClientEvent:supportInfo:]
...
Do I have to perform some extra steps when dispose of my view?
Edit: setting mapView.showsUserLocation to NO in controller's dealloc method seems to help. Still the question is - is it intended behaviour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在dealloc中,在释放mapView之前将其委托设置为nil。
此外,如果您正在使用 ReverseGeocoder 和 CLLocationManager 之类的东西,您可能会想做同样的事情。
In dealloc, before releasing the mapView set its delegate to nil.
In addition, if you are using things like the ReverseGeocoder and a CLLocationManager you'll probably want to do the same thing.