如何在viewDidAppear
中重新加载UIPageViewController?
在那里,我从CoreData刷新信息,我希望在视图出现时更新值。
我尝试使用函数reloadInputViews()
,但仅在您开始打开页面时失败,然后更新信息。
答案 0 :(得分:5)
如果要在UIPageViewController中重新加载ViewControllers,只需将它们重新设置为:
pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool)
如果要从viewController内部更新viewControllers,则必须以这种方式调用它:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
let viewControllers: [UIViewControllers] = [UIViewController()]
if let pageViewController = parentViewController as? UIPageViewController {
pageViewController.setViewControllers(viewControllers, direction: .Forward, animated: true, completion: nil)
}
}