Reputation: 27
It is working in UIView but not in ViewController, I am getting this error "Incorrect argument label in call (have 'frame:', expected 'coder:')", How to solve this one. Please check attache image
init(frame: CGRect) {
super.init(frame: frame)
self.view.backgroundColor=UIColor.clear
currentMonthIndex = Calendar.current.component(.month, from: Date()) - 1
currentYear = Calendar.current.component(.year, from: Date())
setupViews()
btnLeft.isEnabled=true
}
super.init(frame: frame) I am getting error for this line
Upvotes: 2
Views: 3004
Reputation: 100533
UIViewController
doesn't contain frame init it's for a UIView
element only either
let myViewController = MyViewController( )
or
let myViewController = MyViewController(nibName: "MyViewController", bundle: nil)
//
class myViewController:UIViewController {
// put here the properties
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor=UIColor.clear
currentMonthIndex = Calendar.current.component(.month, from: Date()) - 1
currentYear = Calendar.current.component(.year, from: Date())
setupViews()
btnLeft.isEnabled=true
}
}
Upvotes: 5