我创建了一个自定义的inputAccessoryView。在尝试连接按钮的插座后,它显示了Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
我已将其初始化为视图
EmailTF.inputAccessoryView =
Bundle.main.loadNibNamed("SignSubmitBTN", owner: self, options: nil)?.first as! SignSubmitBTN
这是我的自定义类代码:
@IBOutlet weak var signSubmitBTN: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
func setup(){
signSubmitBTN.tintColor! = UIColor.white
}
使用在setup()
signSubmitBTN.tintColor! = UIColor.white
中分配的按钮时出现问题,它将显示
Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
。我想念什么?另外,为什么会指出按钮为nil
?