我們使用
Xib或者Storyboard布局時很多時候會出現(xiàn)以下錯誤:
setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key container
出現(xiàn)以上錯誤的原因很多時候因為我們在為控件命名時,由于命名錯誤,然后按了Ctrl + z撤銷或者你直接把這個控件從類中刪除。但是xib的Outlets中仍然有這個屬性和類對應(yīng),運行時導(dǎo)致出錯。
解決辦法:
找到相應(yīng)的視圖文件Xib或者Storyboard選擇Show the Connections inspector刪除類中不存在的Outlets Connections如下圖所示:

屏幕快照