ios - swift 中 UIAlertView 错误

标签 ios xcode swift

我试图显示一个简单的警报 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 的问题

enter image description here

当您创建 IBOutlet 并从代码中删除时,会出现这种类型的错误(此类与键 keyPath 的键值编码不兼容)

关于ios - swift 中 UIAlertView 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35908692/

相关文章:

iOS UI 测试 iMessage 应用程序/扩展

ios Responder chain - View 如何捕获事件?

ios - dispatch_async(dispatch_get_main_queue(), ^{...});等到完成?

ios - Swift/如何检查可达性

ios - objective c 何时使用 NSDictionary 而不是 NSArray

swift - TableView 在新 Controller 上显示不同的图像

iphone - 向 IB 中的 UIToolbar 项目添加功能

ios - 仅为一个uitableview设置标题

ios - 使用 Alamofire 进行简单的发布请求

ios - 试图弹出一个不存在的 View Controller