'The number of view controllers provided (2) does not match the number required (1) for the requested transition'

1

I'm using TabBarController and I get this error:

  

The number of view controllers provided (2) does not match the number required (1) for the requested transition

When I leave the home screen and come back to it from this error. I think it's strange because the first time I access the home screen I do not receive any errors, it's only when I leave it and I get back, yes I get this error. I've already tried to isdoublesided to true alright but the screen hangs when I rotate it. I'll 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

Being that always falls in if and error is giving the penultimate line before return .mid .

Any help thank you! Thanks!

    
asked by anonymous 04.11.2016 / 20:09

1 answer

1

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

    
07.11.2016 / 13:46