如何解决ZXing 未检测到 iOS 设备上的二维码
我正在创建一个程序来读取 Xamarin 中的二维码。我按照此链接中的步骤操作。
它在 Andriod 上运行良好,但在 iOS 上运行不正常。 我尝试了不同版本的
ZXing.Net.Mobile
ZXing.Net.Mobile.Forms
和测试版也没有给我结果。
这是我的代码。
var scanPageOptions = new MobileBarcodeScanningOptions()
{
AutoRotate = false,TryInverted = true,TryHarder = true,PossibleFormats = new List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE }
};
var scanPage = new ZXingScannerPage(scanPageOptions);
scanPage.IsAnalyzing = true;
scanPage.IsScanning = true;
scanPage.IsTorchOn = true;
scanPage.OnScanResult += (result) =>
{
scanPage.IsScanning = false;
if (result != null)
{
Device.BeginInvokeOnMainThread(async () =>
{
await Navigation.PopAsync();
await displayAlert("Scanned Barcode",result.Text,"OK");
});
}
else
{
Navigation.PopAsync();
displayAlert("Scanned Barcode","No Barcode Found","OK");
}
};
await Navigation.PushAsync(scanPage);
我也尝试了另一种方式。
MobileBarcodeScanner scanner = new MobileBarcodeScanner();
scanner.TopText = "Hold the camera up to the barcode\nAbout 6 inches away";
scanner.BottomText = "Wait for the barcode to automatically scan!";
scanner.AutoFocus();
//This will start scanning
var scanPageOptions = new MobileBarcodeScanningOptions()
{
AutoRotate = false,PossibleFormats = new List<ZXing.BarcodeFormat>() { ZXing.BarcodeFormat.QR_CODE }
};
ZXing.Result result = await scanner.Scan(scanPageOptions);
var msg = "No Barcode!";
if (result != null)
{
msg = "Barcode: " + result.Text + " (" + result.BarcodeFormat + ")";
}
displayAlert("",msg,"Ok");
在 iOS 上没有给出任何结果。 我缺少通过 iOS 设备检测二维码的功能。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。