iPad - PageViewController - 按钮点击显示下一个视图控制器 [英] iPad - PageViewController - Show next view controller on button click

查看:81
本文介绍了iPad - PageViewController - 按钮点击显示下一个视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在我的应用程序中使用UIPageViewController,它显示了与书类似的所有图像。它的工作正常。


我现在想做什么:


我想在左上角放置一个按钮,点击它会显示一个弹出视图控制器它有一个包含7个单元格的表视图。每个单元格将显示不同的URL。单击表格单元格,它将推送一个带有Web视图的视图控制器。


I'm using UIPageViewController in my application that shows all the images similar to a book. Its working fine.
What I want to do now:
I want to place a button on top left corner and on click it will show a pop over view controller which has a table view with 7 cells. Each cell will show different URL. On click of the table cell, it will push a view controller with web view.

问题是什么
问题是我将按钮放在左上角并创建了一个显示popover的segue。但是点击按钮它会转到上一页,然后在下一次点击它最终到达页面1.然后在第1页,它将显示弹出窗口。我不明白为什么会这样发生。

What's the problem The problem is that I placed the button on top left and created a segue to show popover. But on click of button it goes to previous page and on next clicks it will finally reach page 1. then in page 1, it will show the pop over. I didn't understand why is it happening like this.

即使在显示popover后,它也没有显示网站的下一个视图。

And even after showing popover, its not showing next view with website.

怎么做?

推荐答案

诀窍是UIPageViewController的手势识别器接管了那个区域。特别是水龙头处理器;所以你的按钮只有在点击识别器没有意思到达上一页时才被击中。

The trick is that UIPageViewController's gesture recognizers take over that area. In particular, the tap handler; so your button only gets hit when the tap recognizer does not take it as meaning to go to the previous page.

最快的解决方案是将自己设置为其识别器的代表

Quickest solution is to set yourself to the delegate of its recognizers

for (UIGestureRecognizer *recognizer in pageViewController.gestureRecognizers)
  recognizer.delegate = self;

然后实施委托告诉他们让控件接触

and then implement the delegate telling them to let controls get touches

- (BOOL)gestureRecognizer:(UIGestureRecognizer *) __unused gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
   if ([touch.view isKindOfClass:[UIControl class]])
      return NO;
   return YES;
}

应该很好地排序你。

这篇关于iPad - PageViewController - 按钮点击显示下一个视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆