[英]Route-Me TapOnMarker hideLabel won't hide all other marker labels but crashes
I seem to be having a little trouble getting the route-me markers to hide. 我似乎在隐藏路由我标记方面遇到了一些麻烦。 They seem to show fine but if I try to hide them with a for loop it seems to crash.
它们似乎显示良好,但是如果我尝试使用for循环将其隐藏,则似乎会崩溃。 Here is what I have:
这是我所拥有的:
- (void) tapOnMarker: (RMMarker*) marker onMap: (RMMapView*) map{
NSArray* markers = mapView.markerManager.markers;
for(RMMarker *mk in markers) {
[mk hideLabel];
}
[marker showLabel];
}
The for loop in theory should loop through all the markers that are in the marker manager and hide them, but instead it crashes out with this error message: 理论上,for循环应循环遍历标记管理器中的所有标记并将其隐藏,但相反,它会因以下错误消息而崩溃:
-[RMMapLayer hideLabel]: unrecognized selector sent to instance 0x83f7680
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RMMapLayer hideLabel]: unrecognized selector sent to instance 0x83f7680'
*** First throw call stack:
(0x1b91012 0x1959e7e 0x1c1c4bd 0x1b80bbc 0x1b8094e 0x4afa 0x6978a 0x8d433f 0x8d4552 0x8b23aa 0x8a3cf8 0x256bdf9 0x256bad0 0x1b06bf5 0x1b06962 0x1b37bb6 0x1b36f44 0x1b36e1b 0x256a7e3 0x256a668 0x8a165c 0x2b75 0x2a75)
libc++abi.dylib: terminate called throwing an exception
Looking at this error message closely I do notice something, Why is it calling RMMapLayer? 仔细查看此错误消息,我确实注意到了什么,为什么调用RMMapLayer? the hideLabel function is in RMMarker class.
hideLabel函数位于RMMarker类中。 I do specifically write it as "RMMarker *mk in markers".
我确实将其具体写为“标记中的RMMarker * mk”。 What am I doing wrong here?
我在这里做错了什么? Thanks ahead for any help you can offer.
在此先感谢您提供的任何帮助。
Try something like this in your for loop: 在您的for循环中尝试以下操作:
if ([mk isKindOfClass:[RMMarker class]])
[mk hideLabel];
else
NSLog(@"We have a different class here: %@", [mk class]);
You could also use the "respondsToSelector" method to prevent it... 您也可以使用“ respondsToSelector”方法来防止它...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.