gpt4 book ai didi

swift - 使用 Swift 显示签名 View

转载 作者:行者123 更新时间:2023-11-28 11:56:07 25 4
gpt4 key购买 nike

大家好,我正在尝试以可编程的方式在我的应用程序中实现 YPDrwanSignatureView!为此,我使用下面的代码,但是当我运行代码时,出现此错误,我该如何解决?

错误:

 0x10cdbf267 <+519>: movq   %r10, -0xc8(%rbp)
0x10cdbf26e <+526>: movq %r11, -0xd0(%rbp)
0x10cdbf275 <+533>: callq 0x10ce0995e ; symbol stub for: Swift._fatalErrorMessage(Swift.StaticString, Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never
0x10cdbf27a <+538>: movq -0xb0(%rbp), %rax
0x10cdbf281 <+545>: movq 0x684f8(%rip), %rsi ; "addSubview:"

Github 项目: https://github.com/GJNilsen/YPDrawSignatureView

Swift 代码:

import UIKit

class FirmaViewController: UIViewController, YPSignatureDelegate {

// Connect this Outlet to the Signature View
@IBOutlet weak var signatureView: YPDrawSignatureView!

/*required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}*/

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

// Setting this view controller as the signature view delegate, so the didStart() and
// didFinish() methods below in the delegate section are called.
// signatureView.delegate = self
self.view.addSubview(signatureView)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

// 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) {
if let signatureImage = self.signatureView.getSignature(scale: 10) {

UIImageWriteToSavedPhotosAlbum(signatureImage, nil, nil, nil)
self.signatureView.clear()
}
}*/

func didStart() {
print("Started Drawing")
}

func didFinish() {
print("Finished Drawing")
}

最佳答案

如果您在 Storyboard中创建了 YPDrawSignatureView 并为其创建了一个 IBOutlet,则您的 YPDrawSignatureView 已经添加到 viewController。
你不需要调用 self.view.addSubview(signatureView)

关于swift - 使用 Swift 显示签名 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50922700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com