UIScreenEdgePanGestureRecognizer在iPad上运行的iPhone应用程序上无法识别



我有一个仅限iPhone的应用程序,它使用UIScreenEdgePanGestureRecognizer在UINavigationController中实现自定义交互式过渡。手势识别器在 UINavigationController 子类的 viewDidLoad 中创建和添加如下:

UIScreenEdgePanGestureRecognizer* edgeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
edgeRecognizer.edges = UIRectEdgeLeft;
[self.view addGestureRecognizer:edgeRecognizer];
当应用程序在

iPad上运行时,当我尝试滑动以从导航堆栈弹出视图控制器时,应用程序中没有任何反应,如果我在应用程序窗口左侧启动手势,我会得到以下控制台输出:

_UIApplicationHandleEventFromQueueEvent意外的零窗口, _windowServerHitTestWindow: ;层 =>

有谁知道原因以及我如何/是否可以解决此问题?到目前为止,我在文档中找不到任何表明边缘平移手势不应在兼容模式下运行的内容。我正在 iOS 8 中进行测试。

该手势在模拟器中有效,但在设备上无效。

如果使用动画 y 默认创建的视图控制器和导航控制器正确创建故事板(边缘向左轻扫以展开)。但是,如果不是您的情况,您可以尝试使用UnwindSegue或关闭功能。但我不知道"平移:"方法有什么作用。

我在Ipad的一个应用程序中做到了,它正确地调用了该函数:

- (void)viewDidLoad
{
    UIScreenEdgePanGestureRecognizer *leftEdgeGesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self
                                                                                                          action:@selector(openLeftSideBar)];
    leftEdgeGesture.edges = UIRectEdgeLeft;
}
- (void)openLeftSideBar
{
    //the code
}

在这种情况下,您可以对要回滚的视图控制器调用 Unwind segue,或者如果要回滚的视图控制器就在当前视图控制器的后面,请使用如下所示的 disposition 函数:

[self dismissViewControllerAnimated:YES completion:nil];

相关内容

最新更新