自定义输入附件视图意外找到nil,同时隐式展开Optional值

时间:2019-04-11 15:24:49

标签: ios swift

我创建了一个自定义的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

0 个答案:

没有答案