gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 06:14:37 25 4
gpt4 key购买 nike

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

UIScreenEdgePanGestureRecognizer* edgeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
edgeRecognizer.edges = UIRectEdgeLeft;
[self.view addGestureRecognizer:edgeRecognizer];

当应用程序在 iPad 上运行时,当我尝试滑动以从导航堆栈中弹出 View Controller 时,应用程序中没有任何反应,如果我在应用程序窗口是:

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: ; layer = >

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

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

最佳答案

如果您使用默认情况下创建动画的 View Controller 和导航 Controller 正确创建 Storyboard(向左滑动即可展开)。但如果不是你的情况,你可以尝试使用 UnwindSegue 或 dismiss 函数。但我不知道“pan:”方法有什么作用。

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

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

- (void)openLeftSideBar
{
//the code

}

在你的情况下,你可以调用一个 Unwind segue 到你想要回滚的 View Controller ,或者如果你想要回滚的 View Controller 就在当前 View Controller 的后面,请使用这样的关闭函数:

[self dismissViewControllerAnimated:YES completion:nil];

关于ios - 在 iPad 上运行的 iPhone 应用程序无法识别 UIScreenEdgePanGestureRecognizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27866111/

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