【发布时间】:2020-02-14 07:34:32
【问题描述】:
我有一个 UIPageController,其中包含两个子视图控制器。开始时,当用户未获得授权时,我试图执行从 SubViewControllerOne 到 LoginViewController 的 segue。我在 viewDidAppear 中有一个 segue,如下所示:
performSegue(withIdentifier: "authorizeSegue", sender: self);
这会产生不成功的转场和警告
Warning: Attempt to present <Volley.LoginViewController: 0x7f98bd801e00> on <Volley.SubViewControllerOne: 0x7f98bd608400> whose view is not in the window hierarchy!
我在过去使用 ViewControllers 和 TabBarViewControllers 成功地做到了这一点。
当我将 segue 包装在计时器中或通过 IBAction 触发时,segue 工作得非常好。我相信它与 PageViewController 有关。
class PageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate, UIScrollViewDelegate {
var subViewControllers = [UIViewController]()
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
self.dataSource = self
self.edgesForExtendedLayout = [];
// Do any additional setup after loading the view.
let subViewControllerOne = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SubViewControllerOne") as! SubViewControllerOne
let subViewControllerTwo = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SubViewControllerTwo") as! SubViewControllerTwo
subViewControllers = [yourPodcastViewController, appearancesViewController]
setViewControllers([subViewControllers[0]], direction: .forward, animated: true, completion: nil)
}
required init?(coder: NSCoder) {
super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
}
【问题讨论】: