ios - UIScreenEdgePanGestureRecognizer 在自定义键盘扩展中不起作用

标签 ios ios8 uikit ios-app-extension ios-keyboard-extension

问题

我无法使用 UIScreenEdgePanGestureRecognizer 在自定义键盘扩展中识别从屏幕右边缘或左边缘的边缘滑动。我创建了一个新项目来测试这个。其他 UIGestureRecognizer 工作正常,如下所述。

例子

@implementation KeyboardViewController // A subclass of UIInputViewController
...
-(void)viewDidLoad {
  ...
  UIScreenEdgePanGestureRecognizer *gestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture)];
  [gestureRecognizer setEdges:UIRectEdgeAll];
  [self.view addGestureRecognizer:gestureRecognizer];
}

- (void)handleGesture
{
  NSLog(@"gesture handled");
}

Download my example project on Github

可能的解决方法

如果我将其更改为 UIPanGestureRecognizerUITapGestureRecognizer,我会在控制台中看到 gesture handled。我可以使用 UIPanGestureRecognizer,它只接受从屏幕边缘附近开始的手势。

Kiwi Keyboard使用这样的解决方法。

警告:UIPanGestureRecognizer 仅在 self.view 具有背景色时才有效。

最佳答案

据我所知,尽管名为 edges,UIScreenEdgePanGestureRecognizeredges 必须设置为单边。 UIRectEdgeAll 将不起作用,您必须为每个边缘创建一个 UIScreenEdgePanGestureRecognizer,您不能将边缘连接在一起。

关于ios - UIScreenEdgePanGestureRecognizer 在自定义键盘扩展中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26790251/

相关文章:

ios - 转换矩形 : toView: returns double size and twice the distance from the origin

ios - 通过传递数据。导航 Controller

objective-c - 使一系列按钮的响应都不同

iphone - 在 firstResponder 上显示 UITextField 键盘,即使 userInteractionEnabled = NO

ios - 如何在 Swift 中搜索包含结构元素的数组?

swift - SKShapeNode fillTexture 有时无法与 Swift 一起使用

ios - 是否可以为 MKMapView 上的用户定位 Pin 设置固定的屏幕位置?

ios - ADALiOS AcquireToken()

ios - 自定义大小 UIModalPresentationFormSheet 在键盘显示时返回默认大小

当用户在 UIImagePickerController 中移动和缩放后拒绝对照片的权限时,iOS 应用程序崩溃