Fatal error: use of unimplemented initializer in custom navigationcontroller

后端 未结 3 500
情话喂你
情话喂你 2020-12-29 19:49

I\'m creating a custom navigation controller. I have something like this:

public class CustomNavigationController: UINavigationController {

    // MARK: - L         


        
3条回答
  •  遥遥无期
    2020-12-29 20:24

    I had this issue happen to users on iOS 12.4, so to do a workaround in my custom initializer I did something like this:

    init(rootViewController: UIViewController, numberOfPages: Int) {
        self.numberOfPages = numberOfPages
        if #available(iOS 13.0, *) {
            super.init(rootViewController: rootViewController)
        } else {
            super.init(nibName: nil, bundle: nil)
            self.viewControllers = [rootViewController]
        }
    }
    

    I basically initialize my class differently for every iOS version below 13. This does seem like the shortest solution.

提交回复
热议问题