Swift和Xcode Thread 1:在YPDrawSignatureView上发出SIGABRT错误信号

时间:2018-04-04 09:08:49

标签: digital-signature

我尝试使用YPDrawSignatureView使用Xcode 9.3版本为我的Swift 3.3项目制作电子签名。

首先,我将YPDrawSignatureView.swift拉到我的项目中。

enter image description here

我制作了两个按钮和一个UIImage到Main.storyboard。这些对象被拉到我的ViewController.swift,最后我在ViewController.swift中编写了我的示例代码:

import UIKit

class ViewController: UIViewController, YPSignatureDelegate {

    @IBOutlet weak var signatureView: YPDrawSignatureView!

    // Function for clearing the content of signature view
    @IBAction func clearSignature(_ sender: UIButton) {
        // This is how the signature gets cleared
        self.signatureView.clear()
    }

    // Function for saving signature
    @IBAction func saveSignature(_ sender: UIButton) {
        // Getting the Signature Image from self.drawSignatureView using the method getSignature().
        if let signatureImage = self.signatureView.getSignature(scale: 10) {
            // Saving signatureImage from the line above to the Photo Roll.
            // The first time you do this, the app asks for access to your pictures.
            UIImageWriteToSavedPhotosAlbum(signatureImage, nil, nil, nil)
            // Since the Signature is now saved to the Photo Roll, the View can be cleared anyway.
            self.signatureView.clear()
        }
    }

    // didStart() is called right after the first touch is registered in the view.
    // For example, this can be used if the view is embedded in a scroll view, temporary
    // stopping it from scrolling while signing.
    func didStart() {
        print("Started Drawing")
    }

    // didFinish() is called rigth after the last touch of a gesture is registered in the view.
    // Can be used to enabe scrolling in a scroll view if it has previous been disabled.
    func didFinish() {
        print("Finished Drawing")
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        signatureView.delegate = self
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

}

当我尝试运行我的应用时,我收到了来自Xcode的错误消息:

enter image description here

这是输出窗口:

2018-04-04 10:57:17.936377 + 0200 Alairas3 [413:70689] *由于未捕获的异常'NSUnknownKeyException'终止应用程序,原因:'[setValue:forUndefinedKey:]:此类不是键符号编码 - 符合关键的clearSignature。 * 第一次抛出调用堆栈: (0x183496d8c 0x1826505ec 0x1834969f0 0x183dec44c 0x18d5085d4 0x18d94ba08 0x1833a4b24 0x18d6d90e4 0x18d50aadc 0x18d14e0f0 0x18d072b90 0x18d072acc 0x18d063d60 0x18d062b94 0x18d0f06a8 0x18d0662f0 0x18d03365c 0x18d663a0c 0x18d032e4c 0x18d032ce8 0x18d031b78 0x18dcc772c 0x18d031268 0x18daac9b8 0x18dbfaae8 0x18d030c88 0x18d030624 0x18d02d65c 0x18d02d3ac 0x185c94470 0x185c9cd6c 0x101735220 0x101741850 0x185cc8878 0x185cc851c 0x185cc8ab8 0x18343f404 0x18343ec2c 0x18343c79c 0x18335cda8 0x18533f020 0x18d33d78c 0x1009b0ae4 0x182dedfc0) libc ++ abi.dylib:以NSException类型的未捕获异常终止

请帮助我,出了什么问题?

0 个答案:

没有答案