您的当前位置:首页正文

fatal error: init(coder:) has no

来源:华拓网
required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

This is caused by the absence of the initializer init(coder aDecoder: NSCoder!)
on the target UIViewController

That method is required because instantiating a UIViewController from a UIStoryboard calls it.
  1. First method
    Manually implementing init(coder aDecoder: NSCoder!)
    on the target UIViewController
    init(coder aDecoder: NSCoder!) { super.init(coder: aDecoder)}
  2. Second method
    Removing init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?)
    on your target UIViewController
    will inherit all of the required initializers from the superclass asDave Wood pointed on his below