UIView initializer swift Xcode 6 beta 5 [duplicate

2019-04-13 00:44发布

问题:

This question already has an answer here:

  • Class does not implement its superclass's required members 4 answers

xcode 6 beta 5

Error:

Class 'ClassName' does not implement its superclass's required members

on

    class ClassName:UIView

also showing an error

on

        init(frame: CGRect) {
            super.init(frame: frame)
            // Initialization code
            self.backgroundColor = UIColor.clearColor()
        }

Overriding declaration required an 'ovveride' keyword

I placed override before init, ovveride error was remove but superclass error was not

thanks in advance

回答1:

in Xcode6 beta5 the -init(coder:) has became a required method to be overridden:

 class ClassName: UIView {

    required init(coder aDecoder: NSCoder!) {
        super.init(coder: aDecoder)
        // ...
    }

    //

    override init(frame: CGRect) {
        super.init(frame: frame)
        // ...
    }

}


标签: ios swift xcode6