UIPageViewController 让 UItalkeViewController 在 iOS 13 上“跳跃”

Posted

技术标签:

【中文标题】UIPageViewController 让 UItalkeViewController 在 iOS 13 上“跳跃”【英文标题】:UIPageViewController makes UItalkeViewController "jump" on iOS 13 【发布时间】:2019-09-09 16:18:45 【问题描述】:

我有一个带有 UIPageViewControllerios 应用程序,它有 2 个 VC:

    带有“SOS 屏幕”的经典 UIViewController UITabBarViewController 带有 3 个标签,第一个是 UITableViewController 带有“收件箱”

UIPageViewController.viewDidLoad 中我将UITabBarViewController 设置为选中页面。

这在 iOS 10、11 和 12 中运行良好,但 iOS 13(使用 Xcode 11 构建)存在问题

UITabBarViewController 显示时,它处于关闭状态,底部安全区域下方的标签栏和状态栏上方的导航栏。当我滑动到左侧的 UIViewController 并返回到 UITabBarViewController 时,它会“跳跃”并正确布局:

任何想法如何处理它?我尝试将UIPageViewController 替换为自定义UIViewController,并将两个VC 添加到滚动视图中,但这会导致其他问题、中断手势等。我需要一种方法来修复UIPageViewController

【问题讨论】:

您可以使用 UIScrollview 并向其添加子视图控制器 这正是我尝试的原因,写在我的问题中。但它会产生额外的问题,比如破坏后退导航手势, 【参考方案1】:

只要把它放在你的 ViewDidLoad 函数中:

self.tabBarController?.selectedIndex = 1
self.tabBarController?.selectedIndex = 0

这是一个临时修复,但它有效。

【讨论】:

以上是关于UIPageViewController 让 UItalkeViewController 在 iOS 13 上“跳跃”的主要内容,如果未能解决你的问题,请参考以下文章

Swift pagecontroller 故事板 UI 对象与 UIPageviewcontroller 连接

如何让 UIPageViewController 自动切换控制器

如何让 uipageviewcontroller 转圈

旋转到横向时如何让 UIPageViewController 工作?

如何让 UIPageViewController 使用过渡样式滚动?

UIPageViewController 让 UItalkeViewController 在 iOS 13 上“跳跃”