我试图显示一个简单的警报 View 作为创建更改计算器应用程序的第一步,但到目前为止每次我尝试模拟该应用程序时,它都会崩溃并且无法运行。我的代码是...
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.
}
@IBAction func showMessage(sender: UIButton) {
let alertController = UIAlertController(title: "Welcome to the Change Calculator", message: "Do you wish to continue?", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
}
我得到的错误如下...
2016-03-09 23:47:16.385 ChangeMaker[5011:156406] Failed to set (keyPath) user defined inspected property on (UIView): [<UIView 0x7f8210d6fe30> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key keyPath.
2016-03-09 23:47:16.386 ChangeMaker[5011:156406] Failed to set (keyPath) user defined inspected property on (UIView): [<UIView 0x7f8210d6fe30> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key keyPath.
或者有时它会将我发送到 AppDelegate.swift
部分,并表示存在某种问题。只是好奇是否有人知道该问题的解决方案。
最佳答案
这不是您的更改 View 问题,请检查 xib 或 Storyboard并检查连接检查器并删除看起来像 txtPropertyType 的问题
当您创建 IBOutlet 并从代码中删除时,会出现这种类型的错误(此类与键 keyPath 的键值编码不兼容)
关于ios - swift 中 UIAlertView 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35908692/