我已经多次询问与我类似的问题,但是,在我的情况下,我以非常规方法设置了export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
。在过去的一天半中,我试图将其他问题解决方案应用到我的程序中,我开始相信它们只能使用更传统的方法来设置UIPageViewController
。在某些背景下,我有两个UIPageViewController
正在UIViewControllers
之间进行转换。我希望能够以编程方式从其中一个视图控制器更改UIPageViewController
的页面。
这是我的UIPageViewController
课程:
UIPageViewController
我试图在我的VC1中使用这段代码翻转页面:
class transitionController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
lazy var arrayVC: [UIViewController] = {
return [
self.VCInstance(name: "VC1"),
self.VCInstance(name: "VC2")
]
}()
private func VCInstance(name: String) -> UIViewController {
return UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: name)
}
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
self.delegate = self
if let VC1 = arrayVC.first{
setViewControllers([VC1], direction: .forward, animated: true, completion: nil)
}
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = arrayVC.index(of: viewController) else{
return nil
}
guard FIRAuth.auth()?.currentUser?.uid != nil else {
return nil
}
let previousIndex = viewControllerIndex - 1
guard previousIndex >= 0 else {
return nil
}
guard arrayVC.count > previousIndex else{
return nil
}
return arrayVC[previousIndex]
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = arrayVC.index(of: viewController) else{
return nil
}
guard FIRAuth.auth()?.currentUser?.uid != nil else {
return nil
}
let nextIndex = viewControllerIndex + 1
guard nextIndex < arrayVC.count else {
return nil
}
guard arrayVC.count > nextIndex else{
return nil
}
return arrayVC[nextIndex]
}
}
我认为这不起作用,因为我正在创建转换控制器的新实例(我可能是错的)。
如何使用我设置let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "VC2")
transitionController().setViewControllers([vc]?, direction: .Forward, animated: true, completion: nil)
的方法以编程方式从VC1或VC2类中翻转UIPageViewController
的页面?
提前致谢。