从UIPastboard粘贴字符串数据 [英] Paste String Data from UIPastboard

查看:366
本文介绍了从UIPastboard粘贴字符串数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个IOS应用程序,使用OCR扫描条形码并将数据复制到UserDefaults.standard.value(forKey:barcodeId)为!收据中的字符串。我正在尝试自动填充从我设法将数据传递到元素ID的数据,但使用OCR扫描的数据不会填充正确的值。以下来自控制台的信息。注意:我隐藏了URL,因为它是一个私人URL。我需要将可选(8.906010283900207e + 17)传递给基于Web的表单上的元素ID。

I made an IOS app that using OCR to scan barcodes and copies the data to UserDefaults.standard.value(forKey: "barcodeId") as! String from a receipt. I'm trying to auto-populate the data taken from I've managed to pass the data to the element ID, But the data scanned using OCR doesn't populate the correct value. Below information from the console. NOTE: I've obscured the URL, Since It's a private URL. Optional(8.906010283900207e+17) is what I need to pass to the element ID on the webbased form.

谢谢!

错误域= WKErrorDomain代码= 4发生JavaScript异常UserInfo = {WKJavaScriptExceptionLineNumber = 1,WKJavaScriptExceptionMessage = TypeError:null不是对象(评估'document.getElementById ('ERECEIPT')。value = 0890601028390020718'),WKJavaScriptExceptionColumnNumber = 36,WKJavaScriptExceptionSourceURL = https://google.com , NSLocalizedDescription =发生了JavaScript异常}
可选(8.906010283900207e + 17)

Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=1, WKJavaScriptExceptionMessage=TypeError: null is not an object (evaluating 'document.getElementById('ERECEIPT').value = 0890601028390020718'), WKJavaScriptExceptionColumnNumber=36, WKJavaScriptExceptionSourceURL=https://google.com, NSLocalizedDescription=A JavaScript exception occurred} Optional(8.906010283900207e+17)

谢谢!

推荐答案

当您完成条形码扫描时,主要有两个数据到达,一个是条形码,第二个是您扫描的数据。确保何时要粘贴它是有效的字符串数据,然后编写以下代码来复制该条形码数据

when you barcode scan completed then there are mainly two data arrived one is type of barcode and second one is data that you scanned. Make sure when you are going to paste it it is valid string data, then write following code to copy that barcode data

UIPasteboard.general.string = barcodeData

然后在粘贴此数据时,写下以下代码:

Then on the pasting of this data, write following code:

如果让barcodeData = UIPasteboard.general.string {你的代码在这里}

这篇关于从UIPastboard粘贴字符串数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆