0
我有一个页面视图控制器,允许我滚动浏览各种注册页面并输入必要的信息。问题是它只是滚动一圈。我如何制作它,以便PlayerInfo页面是我可以滚动到的最后一页?如何使它成为我的页面视图控制器不是永无止境的?
lazy var SignupArray : [UIViewController] = {
return [self.VCInstance(name: "ParkSelect"),
self.VCInstance(name: "SportSelect"),
self.VCInstance(name: "PlayerInfo")]
}()
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 firstVC = SignupArray.first {
setViewControllers([firstVC], direction: .forward, animated: true, completion: nil)
}
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController?{
guard let viewControllerIndex = SignupArray.index(of: viewController) else {
return nil
}
let previousIndex = viewControllerIndex - 1
guard previousIndex >= 0 else {
return SignupArray.last
}
guard SignupArray.count > previousIndex else {
return nil
}
return SignupArray[previousIndex]
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController?{
guard let viewControllerIndex = SignupArray.index(of: viewController) else {
return nil
}
let nextIndex = viewControllerIndex + 1
guard nextIndex < SignupArray.count else {
return SignupArray.first
}
guard SignupArray.count > nextIndex else {
return nil
}
return SignupArray[nextIndex]
}
介意告诉我你更改或添加什么? – Alexander
@Alexander:正在输入解释发布的代码第一个即所有 –
现在,页面根本不滚动。 – Alexander