简体   繁体   English

如何使用覆盖整个视图的地图视图处理UIScreenEdgeGestureRecognizer?

[英]How to handle a UIScreenEdgeGestureRecognizer with a map view covering the whole view?

I have iOS program over here, with a map view covering the whole container view. 我在这里有iOS程序,地图视图覆盖整个容器视图。 I want the map view to handle the UIScreenEdgeRecognizer , since it is covering the whole container view. 我希望地图视图处理UIScreenEdgeRecognizer ,因为它覆盖整个容器视图。 I think it would be better to let the gestureRecognizers array to reference the recognizer. 我认为gestureRecognizers数组引用识别器会更好。 But the pan gesture of the map view is interrupting the screen edge recogniser. 但是地图视图的平移手势正在中断屏幕边缘识别器。 I tried gestureRecognizer:shouldFailRequireFailureOfGestureRecognizer and all that, but it still doesn't work. 我尝试过gestureRecognizer:shouldFailRequireFailureOfGestureRecognizer等等,但它仍然无法正常工作。 But solution would you people recommend? 但是人们会推荐解决方案吗? Could I let the gestureRecognizers array of the container view reference the screen edge recogniser? 我可以让容器视图的gestureRecognizers数组引用屏幕边缘识别器吗?

What I did was to add a view with a 10pt width and clear color background over the edge I needed the gesture recognizer and I added the gesture recognizer to this view. 我所做的是在边缘上添加宽度为10pt且色彩背景清晰的视图,我需要手势识别器,并将手势识别器添加到此视图中。

In the picture, the white rectangle on the right is the view which will have the gesture recognizer. 在图片中,右侧的白色矩形是具有手势识别器的视图。 You should change the background color to clear color. 您应该更改背景颜色以清除颜色。

一种在地图视图上添加UIScreenEdgePanGestureRecognizer的方法

The view outlet: 视图出口:

@property (weak, nonatomic) IBOutlet UIView *rightEdgeGestureView;

Add the gesture recognizer to the view on the screen right edge: 将手势识别器添加到屏幕右边缘的视图中:

- (void)setupGestureRecognizer {

      UIScreenEdgePanGestureRecognizer *gestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(gestureHandler:)];
      gestureRecognizer.edges = UIRectEdgeRight;
      [_rightEdgeGestureView addGestureRecognizer:gestureRecognizer];
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM