代码如下:
[_mapview removeAnnotations:_mapview.annotations];
运行崩溃,错误信息如下:
BaiduMapSW[7782:707] *** Terminating app due to uncaught exception 'NSGenericException', reason:
'*** Collection <__NSArrayM: 0x2c1690> was mutated while being enumerated.'
*** First throw call stack:
解决方法:
NSArray* array = [NSArray arrayWithArray:_mapView.annotations];
[_mapView removeAnnotations:array];
本文介绍了一种解决iOS地图应用程序在移除注记时出现崩溃的方法。通过使用NSArray复制注记列表,避免了在枚举过程中修改集合导致的崩溃问题。
879

被折叠的 条评论
为什么被折叠?



