ModalViewController 打开时禁用 UIPageViewController

发布于 2024-12-29 15:25:48 字数 403 浏览 2 评论 0原文

我对这个网站完全陌生,但我已经喜欢它了:-)

我通过搜索有关 UIPageViewController 的问题找到了它。

我有一个普通的 UIPageViewController 应用程序,在其中打开一个 ModalViewController 来设置一些设置...

现在的问题: :-)

如果我单击 ModalView 右侧的完成按钮,要关闭它,PageViewController 会翻页,因为他认为该点击是他的意思;-)

只要打开了 ModalView,我就可以禁用 PageViewController GestureRecognizer 吗?

有没有办法禁用他的识别器?

感谢您提前提供的帮助...

cu Matze

I am totaly new to this site, but I already like it :-)

I found it by searching for a question about the UIPageViewController.

I have a normal UIPageViewController App, in which I open a ModalViewController for setting up some settings...

Now the Problem: :-)

If I click on the done Button on the right side of the ModalView, to dismiss it, the PageViewController turnes the page, because he thinks that he is meant by that click ;-)

Can I disable the PageViewController GestureRecognizer as long as I have a ModalView opened?

Is there a method to disable and later his recognizer?

thank you for your help in advance...

cu Matze

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

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

发布评论

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

评论(1

对风讲故事 2025-01-05 15:25:48

您的 UIPageViewController 会从其上呈现的模态视图中窃取触摸,这似乎很奇怪。除非您将模态视图嵌入到 UIPageViewController 的内容中?

要回答您的问题 - 您可以通过枚举其 gestureRecognizers 属性(NSArray)轻松禁用页面视图控制器的手势识别器:

for (UIGestureRecognizer *gr in [self.pageViewController gestureRecognizers]) {
    [gr setEnabled:NO];
}

稍后使用 setEnabled 重新启用它们:是的。

更新:

在iOS 6中添加了UIPageViewControllerTransitionStyleScroll。使用此转换样式的 UIPageViewController 在 gestureRecognizers 返回的数组中不返回任何手势识别器。据推测,具有这种转换样式的页面视图控制器使用底层的私有 UIScrollView 实例(它的行为就像启用了分页的 UIScrollView ),尽管我还没有检查过这一点。

It seems odd that your UIPageViewController would steal touches from a modal view presented over it. Unless, perhaps, you are embedding the modal view within the content of the UIPageViewController?

To answer your question -- you can easily disable the page view controller's gesture recognizers by enumerating its gestureRecognizers property (an NSArray):

for (UIGestureRecognizer *gr in [self.pageViewController gestureRecognizers]) {
    [gr setEnabled:NO];
}

Re-enable them later with setEnabled:YES.

UPDATE:

In iOS 6 UIPageViewControllerTransitionStyleScroll has been added. UIPageViewControllers that use this transition style return no gesture recognisers in the array returned by gestureRecognizers. Presumably page view controllers with this transition style use an underlying, private UIScrollView instance (it behaves just like a UIScrollView with paging enabled), although I haven't checked this.

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