Zxing Xamarin-forms 自动对焦

问题描述

我正在使用 Zxing 扫描 Xamarin 表单应用程序中的条码, 问题是自动对焦仅在出现扫描页面时工作一次, 我尝试添加计时器如下代码也不起作用, 我注意到当我更改应用程序并返回到它时(在扫描页面中)自动对焦工作完美, 我还添加了 Button 到 Autofocus 来叠加,它被触发但相机没有聚焦
有什么建议吗?

 scanPage.AutoFocus();
            TimeSpan ts = new TimeSpan(0,10,0);
            Device.StartTimer(ts,() =>
            {
                if (scanPage.IsScanning)
                {
                    scanPage.AutoFocus();
                }
                return true;
            }); 

解决方法

不要使用 ScannerPage。 使用他们的 MobileBarcodeScanner。

var scanner = new ZXing.Mobile.MobileBarcodeScanner();
var result = await scanner.Scan();

来自文档:https://github.com/Redth/ZXing.Net.Mobile#usage