I'm trying to change the current ViewController of my UIPageViewController using a NEXT button. So I'm calling the function that's in my containterViewController in my mainViewController using a delegate. But it doesn't execute the setViewControllers line.
Here you can see my code:
This is the method that I call using my delegate:
func forwardPage() {
print("Start")
currentPage += 1
print(vcs[currentPage])
self.setViewControllers([vcs[currentPage]], direction: .forward, animated: true) { (true) in
print("Done")
}
}
Here's my delegate:
protocol WalkthroughViewControllerDelegate {
func forwardPage()
func currentIndex() -> Int
}
And here's the function that is connected to my NEXT button:
@IBAction func nextButtonTapped(_ sender: Any) {
if let index = delegate?.currentIndex() {
print("Here... \(index)")
switch index {
case 0...1:
print("Forwarding...")
delegate?.forwardPage()
case 2:
dismiss(animated: true, completion: nil)
default: break
}
}
updateUI()
}
Everything but the "Done" gets printed
I would really appreciate your help
I've been struggling because of this for quite some time now
Thank you very much :)
EDIT: Maybe this happens because that UIPageViewController is inside a containerView. But I'm not sure
SECOND EDIT: I've created a git-hub repository just for this issue. Here's the link: https://github.com/LennartPhil/App-Popup-Screen. I hope you can understand that I won't show you all of my files.