Are view controllers with nib files broken in ios 8 beta 5?

前端 未结 7 1962
囚心锁ツ
囚心锁ツ 2020-12-01 21:46

I created a test project in ios 8 beta 4 which as a main view controller and a second view controller created as a UIViewController subclass with a xib file.

I put a

7条回答
  •  心在旅途
    2020-12-01 21:52

    I've had this problem recently, and my solution is to override the nibName method in baseviewController. My solution is as follows:

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    init() {
        super.init(nibName: nil, bundle: Bundle.main)
    }
    
    override var nibName: String? {
        get {
            if #available(iOS 9, *) {
                return super.nibName
            } else {
                let classString = String(describing: type(of: self))
                guard Bundle.main.path(forResource: classString, ofType: "nib") != nil else {
                    return nil
                }
                return classString
            }
        }
    }
    

提交回复
热议问题