Must call a designated initializer of the superclass 'UITableView'

Hello guys,


I subclassed UITableView, and before the migration to Swift 2.0, I didn't have any issue compiling the following code.


Now I get : "Must call a designated initializer of the superclass 'UITableView'"


Can you please help me ?


init(headerView: UIView, othertriggerViews: UIView...) {
        super.init(frame: CGRectZero)
        header = headerView
        var helper = [UIView]()
        helper.append(header!)
        helper = helper + othertriggerViews
        trigger = helper
        initialize()
        self.setTapGestureRecognizers()
    }

    init() {
        super.init(frame: CGRectZero)
        initialize()
    }
    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        initialize()
    }

    init(frame: CGRect) {
        super.init(frame: frame)
        initialize()
    }

    override init(frame: CGRect, style: UITableViewStyle) {
        super.init(frame: frame, style: style)
        initialize()
    }

    /
    private func initialize(){
        self.offset = 20
        self.initialHeight = self.frame.size.height
        self.customBackgroundView = UIView(frame: self.frame)
        self.backgroundView = self.customBackgroundView!
    }
Answered by kalel in 7708022

The init changed, the code that fixed the issue is this one


init() {
        super.init(frame: CGRectZero, style: UITableViewStyle.Plain)
        initialize()
    }
    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        initialize()
    }
   
    init(frame: CGRect) {
        super.init(frame: frame, style: UITableViewStyle.Plain)
        initialize()
    }
   
    override init(frame: CGRect, style: UITableViewStyle) {
        super.init(frame: frame, style: style)
        initialize()
    }
Accepted Answer

The init changed, the code that fixed the issue is this one


init() {
        super.init(frame: CGRectZero, style: UITableViewStyle.Plain)
        initialize()
    }
    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        initialize()
    }
   
    init(frame: CGRect) {
        super.init(frame: frame, style: UITableViewStyle.Plain)
        initialize()
    }
   
    override init(frame: CGRect, style: UITableViewStyle) {
        super.init(frame: frame, style: style)
        initialize()
    }
Must call a designated initializer of the superclass 'UITableView'
 
 
Q