ZXing 未检测到 iOS 设备上的二维码

问题描述

我正在创建一个程序来读取 Xamarin 中的二维码。我按照此链接中的步骤操作。

https://siddheshshelke.wordpress.com/2020/08/07/qrcode-generator-and-scanner-for-xamarin-forms-using-zxing-nuget/

它在 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 (将#修改为@)