'The number of view controllers provided (2) doesn’t match the number required (1) for the requested Transition'

Asked

Viewed 189 times

1

I’m using TabBarController and I get this mistake :

The number of view controllers provided (2) doesn’t match the number required (1) for the requested Transition

When I exit the home screen and return to it from this error. I find it strange because the first time I access the home screen I do not get any error is only when I leave it and I return there yes I get this error. I’ve tried to be too isdoublesided for true But the screen hangs when I rotate it. I will post the code :

let currentViewController : PageContentViewController =          self.pageViewController!.viewControllers![0] as! PageContentViewController
    var viewControllers: [UIViewController]

    let indexOfCurrentViewController = self.indexOfViewController(currentViewController)
    if (indexOfCurrentViewController == 0) || (indexOfCurrentViewController % 2 == 0) {
        let nextViewController = self.pageViewController(self.pageViewController!, viewControllerAfter: currentViewController)
        viewControllers = [currentViewController, nextViewController!]
    } else {
        let previousViewController = self.pageViewController(self.pageViewController!, viewControllerBefore: currentViewController)
        viewControllers = [previousViewController!, currentViewController]
    }

    self.pageViewController!.setViewControllers(viewControllers, direction: .forward, animated: true, completion: {done in })
    return .mid

Always falling in the if and error is giving in the penultimate line before return .mid.

Any help thanks! Thanks!

1 answer

1


I solved the problem I was leaving my code inside viewWillAppear , while putting now in viewDidLoad worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.