[英]Page ViewController with 4 viewControllers - How to set view 2 as initial viewController?
I have created a pageViewController with four view controller.我创建了一个带有四个视图控制器的 pageViewController。
Right now the order is:现在的顺序是:
VC1, VC2, VC3, VC4: VC1、VC2、VC3、VC4:
var pageControl = UIPageControl()
var pendingPage: Int?
lazy var viewControllerList: [UIViewController] = {
let sb = UIStoryboard(name: "Main", bundle: nil)
let vc1 = sb.instantiateViewController(withIdentifier: "VC1")
let vc2 = sb.instantiateViewController(withIdentifier: "VC2")
let vc3 = sb.instantiateViewController(withIdentifier: "VC3")
let vc4 = sb.instantiateViewController(withIdentifier: "VC4")
return [vc1, vc2, vc3, vc4]
}()
How can I set VC2 as the initial view controller of the page view controller when the app loads?应用加载时如何将 VC2 设置为页面视图控制器的初始视图控制器? So basically the user can swipe left "and" right to got to from VC2 left to VC1 or right from VC2 to VC3.所以基本上用户可以向左“和”向右滑动以从 VC2 向左滑动到 VC1 或从 VC2 向右滑动到 VC3。
VC1 < VC2 - this is the start view controller > VC3 > VC4 VC1 < VC2 - 这是开始视图控制器 > VC3 > VC4
This is my viewDidLoad():这是我的 viewDidLoad():
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
self.dataSource = self
if let firstViewController = viewControllerList.first {
self.setViewControllers([firstViewController], direction: .forward, animated: true, completion: nil)
}
}
self.setViewControllers([viewControllerList[1]], direction: .forward, animated: true, completion: nil)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.