我试图以自编的方式在我的主视图控制器上放置自定义视图类的视图。这里是我的代码:自定义视图类中init编码器函数的问题
import UIKit
class BarControl: UIView {
// MARK: Initialization
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
let button = UIButton(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
button.backgroundColor = UIColor.redColor()
button.addTarget(self, action: "ratingButtonTapped:", forControlEvents: .TouchDown)
addSubview(button)
}
override func intrinsicContentSize() -> CGSize {
return CGSize(width: 240, height: 44)
}
}
在我主视图控制器:
let myView = BarControl()
的错误出现说:“缺少在调用参数‘编码器’参数”
我应该怎么放在let myView = BarControl()
的括号内?
什么是BarControl类型?你有代码中的'RatingControl',从这里不清楚'BarControl'是什么# –