在ZXing.Mobile.MobileBarcodeScanner

时间:2018-03-30 18:58:25

标签: xamarin zxing

我使用下面的代码来扫描条形码。我已经设置了取消和flash按钮文本,但在UI上看不到它。它在iOS中运行良好,但在Android中运行良好。 见下面的代码

    public async Task StartScan()
    {
        var scanPage = new ZXing.Mobile.MobileBarcodeScanner();
        this.cancelTimer = new CancellationTokenSource();
        scanPage.AutoFocus();
        scanPage.TopText = "Place the barcode between the red line";
        scanPage.CameraUnsupportedMessage = "Camera doesnt supports AUTOFOCUS.";
        scanPage.BottomText = "If it doesnt autofocus, touch the screen to autofocus";
        scanPage.CancelButtonText = "<< Back";
        scanPage.FlashButtonText = "Turn Flash";
        scanPage.UseCustomOverlay = false;

        Device.StartTimer(new TimeSpan(0, 0, 0, 3, 0), () =>
        {
            scanPage.AutoFocus();
            //  scanPage.BottomText = "focusing";
            return true;
        });
        ZXing.Result result = null;
        CancellationTokenSource cts = this.cancelTimer;
        TimeSpan ts = new TimeSpan(0, 0, 0, 2, 0);
        Device.StartTimer(ts, () =>
        {
            if (cts.IsCancellationRequested)
            {
                return false;
            }

            if (result == null)
            {
                scanPage.AutoFocus();
                return true;
            }
            return false;
        });

        result = await scanPage.Scan(new MobileBarcodeScanningOptions
        {
            TryHarder = false,
            AutoRotate = false,
            UseNativeScanning = true,
            PossibleFormats = GetAvailableFormats(),
        });
        if (result != null && !string.IsNullOrWhiteSpace(result.Text))
        {
            await Stop();                
            await ProcessResult(result.Text);
        }
        await Stop();
    }

因此,从上面的代码中可以看到Bottom和Top文本,但不会显示代码如下所示的按钮。  scanPage.CancelButtonText =&#34;&lt;&lt;回到&#34 ;;  scanPage.FlashButtonText =&#34;转动Flash&#34;;

任何人都可以帮我解决这个问题吗?

0 个答案:

没有答案