PageViewController:忽略下一页/上一页手势识别器

发布于 2024-12-15 12:20:17 字数 332 浏览 1 评论 0原文

我有一个应用程序,其中有一个 PageViewController,可以在用户不执行任何操作的情况下连续显示其页面。我想完全阻止用户的访问。在显示所有页面后,我有一个后退按钮出现在顶部。但是,如果我尝试点击它......它会再次开始浏览页面(它位于您通常点击以转到上一页的区域)。

那么,有谁知道我如何“删除”手势识别器?

我尝试评论该行:

self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;

来自 RootViewController 但它不起作用。

I have a app in which I have a PageViewController that shows it's pages on after another without the user doing anything. I want to totally block the user's acces. I have a back button that appears on the top after all of pages have been shown. But if I try to tap it ... it starts going through the pages again (it's in the area that you would usually tap to go to previous page).

So, does anyone have any idea how could I "remove" the gesture recognizers ?

I tried commenting the line :

self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;

from RootViewController but it didn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月野兔 2024-12-22 12:20:17

我自己没有尝试过,它可能不会适合每个人,但对于您的特定情况,因为您正在手动更改它应该工作的所有页面。我在 UIPageViewController 文档中找到了以下内容< /a> 在概述部分。

“仅当数据源已启用时才启用基于手势的导航
提供。”

您仍然需要注释掉上面提到的行,而且还要 self.pageViewController.dataSource = self.modelController;

编辑:我自己测试了一下,它有效。无法导航使用任何手势,但可以通过编程方式。

I haven't tried this myself, and it probably won't be the solution for everyone, but for your particular case because you're manually changing all the pages it should work. I found the following tid-bit in the UIPageViewController documentation in the Overview section.

"Gesture-based navigation is enabled only when a data source is
provided."

You will still want to comment out the line that you mentioned above, but also self.pageViewController.dataSource = self.modelController;

EDIT: Just tested this myself and it works. Can't navigate with any of the gestures, but can programmatically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文