本文介绍了具有4个viewControllers的Page Viewtroller - 如何将视图2设置为初始viewController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有四个视图控制器的pageViewController。

I have created a pageViewController with four view controller.

现在订单是:

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]
}()

如何在应用加载时将VC2设置为页面视图控制器的初始视图控制器?所以基本上用户可以向右滑动和向右滑动从VC2离开到VC1或从VC2向右滑动到VC3。

How can I set VC2 as the initial view controller of the page view controller when the app loads? So basically the user can swipe left "and" right to got to from VC2 left to VC1 or right from VC2 to VC3.

VC1< VC2 - 这是启动视图控制器> VC3> VC4

VC1 < VC2 - this is the start view controller > VC3 > VC4

这是我的viewDidLoad():

This is my 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)

这篇关于具有4个viewControllers的Page Viewtroller - 如何将视图2设置为初始viewController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 13:27