How to subclass UITableViewController in Swift

后端 未结 9 1824
栀梦
栀梦 2020-12-23 11:42

I want to subclass UITableViewController and be able to instantiate it by calling a default initializer with no arguments.

class TestViewController: UITableV         


        
9条回答
  •  伪装坚强ぢ
    2020-12-23 12:23

    I've noticed a similar error when using static tableview cells and you gotta implement this:

    init(coder decoder: NSCoder) {
        super.init(coder: decoder)
    }
    

    if you implement:

    required init(coder aDecoder: NSCoder!) {
            // Or call super implementation
            fatalError("NSCoding not supported")
    }
    

    I was just getting a crash there... Kind of as expected. Hope this helps.

提交回复
热议问题