我一直在尝试将触摸/手势事件从顶部视图发送到底部视图的各种可能性。我正在使用开放框架 GLView。我可以将数据从一个类发送到子类,但 RMMapView 仍然不会覆盖手势和触摸事件。我尝试过使用触摸/手势和 Hittest,但在所有这些上我都无法控制地图视图。这是我尝试转发 pan 事件的地方。
我在 EAGLView.h https://github.com/openframeworks/openFrameworks/blob/master/addons/ofxiPhone/src/EAGLView.h 图层类中做了什么:
UIPanGestureRecognizer *panGestureRecognizer = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)] autorelease];
panGestureRecognizer.minimumNumberOfTouches = 1;
panGestureRecognizer.maximumNumberOfTouches = 1;
[self addGestureRecognizer:panGestureRecognizer];
- (void)handlePanGesture:(UIPanGestureRecognizer *)recognizer
{
NSLog(@"EAGLEVIEW Pan");
for (UIView *view in [ofxiPhoneGetUIWindow() subviews])
{
if([view isKindOfClass:[RMMapView class]])
{
[view handlePanGesture:recognizer];
// [view panGestureRecognizer delegate self];
// [self addGestureRecognizer:recognizer];
}
}
}
https://github.com/route-me/route-me/blob/master/MapView/Map/RMMapView.m RMMapview 的子类:
if (self) {
UIPanGestureRecognizer *panGestureRecognizer = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)] autorelease];
[panGestureRecognizer setDelegate:self];
panGestureRecognizer.minimumNumberOfTouches = 1;
panGestureRecognizer.maximumNumberOfTouches = 1;
NSLog(@"hallo123 %@",self);
[self addGestureRecognizer:panGestureRecognizer];
- (void)handlePanGesture:(UIPanGestureRecognizer *)recognizer
{
NSLog(@"pan");
[recognizer setDelegate:self];
[super handlePanGesture:recognizer];
}