<分区>
<分区>
我正在制作一个小型 iOS 应用程序,用于跟踪我在工作中打卡的时间。我对 Swift 和 Xcode 非常陌生,所以这对我来说是一个挑战。详细信息:我使用的是Xcode 7,目标开发是8.3。我相信我丢失了一些小东西,例如类文件。 应用程序在启动时崩溃。
错误:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key ButtonIn.'
代码:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBOutlet weak var Lb1: UILabel!
@IBAction func ButtonIn(sender: AnyObject) {
self.Lb1.text = "Clocked In!"
}
@IBAction func ButtonOut(sender: AnyObject) {
self.Lb1.text = "Clocked Out!"
}
}
最佳答案
这通常发生在绑定(bind)导出改变时。请按照以下步骤操作:
希望这对您有所帮助。
关于ios - 为什么我在 setValue :forUndefinedKey:? 中得到 NSUnknownKeyException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32700193/
相关文章:
ios - AudioKit Playground (错误 : 'Module compiled with Swift 3.1 cannot be imported in Swift 3.0.2' )
ios - 如何创建自定义 TextCell 和 TextRow,其中包含 UITextField 的子类?
ios - 在 ios 中使用查询字符串创建 NSURLRequest
iphone - 如何访问 UINavigationController 中以前的 View 元素
ios - Swift:如何以编程方式在 View 末尾设置按钮