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

[Bug] When isInfiniteScrollEnabled, ViewController disappears intermittently. #265

Open
KYHyeon opened this issue Sep 25, 2021 · 1 comment

Comments

@KYHyeon
Copy link

KYHyeon commented Sep 25, 2021

When isInfiniteScrollEnabled is true and the scroll direction changes on the last page, the view controller disappears intermittently.
This is easy to reproduce if you have two viewcontrollers.

Here is my code

import UIKit
import Pageboy

class ViewController: PageboyViewController {
    let firstVC: UIViewController = {
        let viewController = UIViewController()
        viewController.view.backgroundColor = .systemOrange
        return viewController
    }()
    
    let secondVC: UIViewController = {
        let viewController = UIViewController()
        viewController.view.backgroundColor = .systemPurple
        return viewController
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.dataSource = self
        self.isInfiniteScrollEnabled = true
    }
}

extension ViewController: PageboyViewControllerDataSource {
    func numberOfViewControllers(in pageboyViewController: PageboyViewController) -> Int {
        2
    }
    
    func viewController(for pageboyViewController: PageboyViewController, at index: PageboyViewController.PageIndex) -> UIViewController? {
        switch index {
        case 0:
            return firstVC
        case 1:
            return secondVC
        default:
            fatalError("unknown index!")
        }
    }
    
    func defaultPage(for pageboyViewController: PageboyViewController) -> PageboyViewController.Page? {
        .first
    }
}
@KYHyeon KYHyeon changed the title When isInfiniteScrollEnabled, ViewController disappears intermittently. [Bug] When isInfiniteScrollEnabled, ViewController disappears intermittently. Sep 25, 2021
@narekam
Copy link

narekam commented May 26, 2022

I can reproduce this in our app, where we have 7 view controllers and isInfiniteScrollEnabled is true/false (doesn't matter) - when you go quickly between view controllers back and forth one of the views would disappear eventually. And then, if you rotate the device app would crash with console output like this

*** Assertion failure in -[Pageboy.PatchedPageViewController _flushViewController:animated:], UIPageViewController.m:2110
2022-05-26 13:54:31.247654-0700 MotorTrend[3956:523518] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Don't know about flushed view <UIView: 0x121f6eac0; frame = (0 0; 1194 503.5); alpha = 0; autoresize = W+H; layer = <CALayer: 0x2831f92c0>>'

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

No branches or pull requests

2 participants