Page ViewController with 4 viewControllers - 如何将视图 2 设置为初始 viewController?
Page ViewController with 4 viewControllers - How to set view 2 as initial viewController?
我创建了一个带有四个视图控制器的 pageViewController。
现在的顺序是:
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]
}()
如何在应用程序加载时将VC2设置为页面视图控制器的初始视图控制器?所以基本上用户可以向左 "and" 向右滑动以从 VC2 向左滑动到 VC1 或从 VC2 向右滑动到 VC3。
VC1 < VC2 - 这是开始视图控制器 > VC3 > VC4
这是我的 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)
我创建了一个带有四个视图控制器的 pageViewController。
现在的顺序是:
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]
}()
如何在应用程序加载时将VC2设置为页面视图控制器的初始视图控制器?所以基本上用户可以向左 "and" 向右滑动以从 VC2 向左滑动到 VC1 或从 VC2 向右滑动到 VC3。
VC1 < VC2 - 这是开始视图控制器 > VC3 > VC4
这是我的 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)