iOS/swift/ Storyboard : Add PageViewController using only *part* of screen?

标签 ios xcode swift uipageviewcontroller xcode-storyboard

Swift 新手。我看过很多关于使用 PageViewController 的教程,但它们总是让页面 View 占据整个屏幕。

我试图仅在我的应用程序的一部分而不是整个屏幕中实现页面 View 功能,以便可以保留其他“静态”元素(例如工具栏)。看起来有点像这样的东西......

https://imgur.com/9wM1vll ---(在嵌入图像之前需要更多的代表)

...滑动会导致出现不同的图像,如各种 PageViewController 教程中所示(例如 http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/)。

当我开始使用单 View 应用程序时,我转到 Storyboard 并尝试将“页面 View Controller ”从对象库拖到 ViewController 框架中,它只是“弹回”,即它不会让我添加页面 View Controller 。

现在,如果我将 Page View Controller 添加到另一个 View Controller 周围的空白区域,那么这将返回到 PageViewController 占据整个屏幕的教程,我不希望这样。

如何实现这一目标?

谢谢。

抱歉,如果这是一个骗局,但我已经尝试过但未能找到任何可以直接回答我的问题的东西。最接近的是 Implement PageViewController in TableViewController detailsAdding a UIPageViewController to a subview, subview only shows edge of pageContentview ,但这些都不够相似,我无法理解,而且它们在我还没有学过的 Objective C 中。

最佳答案

When I start with a Single View Application, I go to Storyboard and try to drag a "Page View Controller" from the Object Library into the ViewController frame, it just "bounces back", i.e. it won't let me add the Page View Controller.

页面 View Controller 是一个 View Controller 。因此,为了让它的 View 只占据屏幕的一部分,你必须遵守 View Controller 的一般规则:你需要一个自定义的父 View Controller ,页面 View Controller 必须是它​​的 subview Controller ——你必须做详细的当您创建子项并将其 View 放入界面时,这需要跳舞。

为了让 Storyboard为您跳起舞来,使用容器 View 并通过其嵌入转场将其挂接到页面 View Controller :

enter image description here

enter image description here

(不过,在我看来,最好自己手动学习,用代码来跳舞。)

关于iOS/swift/ Storyboard : Add PageViewController using only *part* of screen?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32040926/

相关文章:

ios 7 半透明+彩色导航栏

ios - 在 UIWebView iPhone iOS XCode 中打开 SharePoint URL - 将凭据嵌入 URL 请求以避免提示输入凭据

objective-c - JSON解析看不懂

ios - 使用 audiokit 在 AKsequencer 中创建额外 MIDI 轨道的问题

ios - 如何将iOS Objective-C类接口(interface)代码翻译成RubyMotion?

ios - 如何在 Spritekit 中创建一个 SKActions 数组

ios - 如何解释从 SCNetworkReachabilityCreateWithName 返回的空值?

XCode 4.3 命令行工具

ios - 如何在swift中通过泛型实现对象合并?

ios - 我的应用程序是否使用 UIApplication.shared.openURL 调用 HTTPS?