使用 UIPageViewController for iOS 无法正确添加导航按钮 [英] Unable Correctly to Add Navigation Buttons Using UIPageViewController for iOS

查看:17
本文介绍了使用 UIPageViewController for iOS 无法正确添加导航按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的项目 UIPageViewController 可能是一个不错的选择,因此,我从 XCode 6.4 提供的模板开始新项目.我使用了模板:基于页面的应用程序,它已经有了 UIPageViewController 的基本实现.滚动页面的机会工作正常,但是,我也想添加导航栏.阅读有关该主题的文章后,我尝试将 DataViewController 嵌入到 NavigationController (Editor>Embed) 中,然后使用 Interface Builder 中的故事板添加导航栏按钮.但是,编译应用程序时看不到该按钮.此外,当您按下导航栏按钮应位于的位置时,看起来后退导航适用于页面,但按钮不可见.后来我发现后退导航不仅适用于那个位置,而且适用于视图的所有左边距.好像是个bug.

For my project UIPageViewController could be a good choice, so, I started with the template provided by XCode 6.4 starting new project. I used the template: Page-Based Application which has already the basic implementation of UIPageViewController. The opportunity to scroll the pages is working fine, however, I would like to add the navigation bar as well. After reading the articles on that topic I tried to embed DataViewController into NavigationController (Editor>Embed), and then added the Navigation Bar Button using the storyboard from Interface Builder. However, I cannot see that button when I compile the app. Moreover, it looks that the back navigation works for the pages when you press on the spot where Navigation Bar Button should be located, but button is not visible. Later I found out that the back navigation works not only on that spot but on all left margin of the view. It seems like a bug.

1.如何使导航栏返回按钮可见?

2.当导航对按下所有边距而不是按钮的位置做出反应时,如何消除这种错误行为?

推荐答案

如果你想让导航控制器出现,你需要改变:

If you want to have the navigation controller show up, you need to change:

let startingViewController: DataViewController = self.modelController.viewControllerAtIndex(0, storyboard: self.storyboard!)!

这样,startingViewController 就是嵌入 dataViewController 的导航控制器.您可以通过更改导航控制器的故事板 ID 并说如下内容来实现:

so that startingViewController is the navigation controller your dataViewController is embedded in. You can do this by changing the storyboard ID of the navigation controller and saying something like:

let startingViewController: UIViewController = (self.storyboard?.instantiateViewControllerWithIdentifier("NavController"))!

然而,这会破坏模板,因为其余的代码认为起始视图控制器是一个 DataViewController,所以你需要改变它.

However this is going to break the template as the rest of the code thinks the starting view controller is a DataViewController, so you will need to change that.

当 transitionStyle 设置为 UIPageViewControllerTransitionStylePageCurl 时,错误行为"是标准的页面控制器导航机制.

The "buggy behavior" is the standard page controller navigation mechanism when the transitionStyle is set to UIPageViewControllerTransitionStylePageCurl.

这篇关于使用 UIPageViewController for iOS 无法正确添加导航按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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