gpt4 book ai didi

ios - 设置手势委托(delegate)时无法选择 map 对象

转载 作者:行者123 更新时间:2023-12-01 16:15:50 26 4
gpt4 key购买 nike

这是与 相关的问题。这里 iOS HybridPlus SDK .

如果与类 NMAMapView 的 mapView 进行了任何交互和 NMAMapViewDelegateNMAMapGestureDelegate两者都设置然后只有 NMAMapGestureDelegate 的方法正在被调用。

例如:

如果点击 map 上的对象,则 - mapView:didReceiveTapAtLocation:被调用并 - mapView:didSelectObjects:不会被调用!

而在android中情况并非如此。在 android 中,如果一个对象被点击并且两个代表都被设置,那么上面提到的两个方法都会被调用。

问题:在 iOS 中解决这个问题的方法是什么?

最佳答案

得到这个答案HERE 开发支持 .

The mapView:didSelectObjects: is not getting called, because they are overriding the default tap handler by implementing mapView:didReceiveTapAtLocation in their NMAMapGestureDelegate. Because this is a protocol, they cannot call mapView:didReceiveTapAtLocation of the super class to run the default implementation, after they perform operation they need. However objects passed to mapView:didSelectObjects: are retrieved in a standard way, which is available to the customer, therefore they can mimic the default implementation, for example:

- (void)mapView:(NMAMapView *)mapView didReceiveTapAtLocation:(CGPoint)location  {

NSLog(@"didReceiveTapAtLocation: %fx%f", location.x, location.y);
if ([mapView.delegate respondsToSelector:@selector(mapView:didSelectObjects:)]) {
// Check to see if any objects are selected
NSArray *selectedObjects = [mapView visibleObjectsAtPoint:location];
// If any objects were selected, treat the tap as a selection
if (selectedObjects.count > 0) {
[mapView.delegate mapView:mapView didSelectObjects:selectedObjects];
}
}
}

关于ios - 设置手势委托(delegate)时无法选择 map 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29642882/

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