This code works:
import UIKit
class wheel: UIControl {
}
But this code doesn't:
class wheel: UIControl {
override init(frame: CGRect) {
super.init(frame: frame)
}
It shows error "required initializer init must be provided in subclass of UIControl
" when I override init(frame: CGRect) but not init(coder aDecoder: NSCoder)
.
Why do I have to implement init(coder aDecoder: NSCoder)
? And why don't I need to implement it if I didn't implement init(frame: CGRect)
?
I found a similar Stack Overflow post but it didn't explain: Swift : Error: 'required' initializer 'init(coder:)' must be provided by subclass of 'UIView'