Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with message "Invalid parameter not satisfying: [views count] == 3" + FIX #140

Closed
salvasp opened this issue Feb 10, 2018 · 3 comments
Labels

Comments

@salvasp
Copy link

salvasp commented Feb 10, 2018

If swipe quickly between pages I sometime get the error inconsistent exception "Invalid parameter not satisfying: [views count] == 3"

seems can be fixed replacing inside "open class PageboyViewController: UIViewController"

pageViewController.setViewControllers(viewControllers,
                                                  direction: direction.pageViewControllerNavDirection,
                                                  animated: false,
                                                  completion:
                { (finished) in
                    self.isUpdatingViewControllers = false
                    
                    if !animated {
                        completion?(finished)
                    }
            })    

with

     DispatchQueue.main.async {
            pageViewController.setViewControllers(viewControllers,
                                                  direction: direction.pageViewControllerNavDirection,
                                                  animated: false,
                                                  completion:
                { (finished) in
                    self.isUpdatingViewControllers = false
                    
                    if !animated {
                        completion?(finished)
                    }
            })            
        }
@msaps
Copy link
Member

msaps commented Feb 12, 2018

@salvasp thanks for all the detail, just released a new version with this fix in. Let me know how you get on with it! 😄 v2.3.4

@msaps msaps added the bug label Feb 12, 2018
@salvasp
Copy link
Author

salvasp commented Feb 13, 2018

yes seems to work.
Have you panned something like extending
func viewController(for pageboyViewController: PageboyViewController, at index: PageboyViewController.PageIndex) -> UIViewController?
with somentig like
func viewController(for pageboyViewController: PageboyViewController, at index: PageboyViewController.PageIndex, reusingViewController: UIViewController?) -> UIViewController?
to reuse the cached view controllers?
I commented the issue #124 with some idea but for now I'm using in one case the variable [UIViewController?] (in the comments after the NSCache row) because i have just 6 view controllers.
in another case 50+ view controllers I create a view controller (let controller = storyboard.instatiate....; return controller) each time "viewController for" is called

@msaps
Copy link
Member

msaps commented Feb 13, 2018

@salvasp I'll take a look! Reuse / improved insertion is high on the list for Pageboy 3, so hopefully will get to start working on it shortly 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants