Riccardo Daria

Riccardo Daria

  • 1.3k
  • 74
  • 5.2k

The code belove works only the first time

May 30 2023 10:28 AM

The code below doesn't work correctly, it works only on first appearance of the page, after the first scanning if you go back to previous page and return to this page. the scanner doesn't works!!!! try yourself and tell my something about thanks

<StackLayout>
        <Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
            <Label Text="Barcode Sample" HorizontalTextAlignment="Center" TextColor="White" FontSize="36" />
        </Frame>
        <Label x:Name="scanResultText" />
        <zxing:ZXingScannerView IsScanning="True"   OnScanResult="ZXingScannerView_OnScanResult" x:Name="fotoCamera" />
        <Button Text="" Clicked="AvviaScanner" />
public partial class PageScanner : ContentPage
{

    public PageScanner()
    {
        InitializeComponent();
    }

    void ZXingScannerView_OnScanResult(ZXing.Result result)
    {
        Device.BeginInvokeOnMainThread(() =>
        {
            scanResultText.Text = result.Text + " (type: " + result.BarcodeFormat.ToString() + ")";
            //Application.Current.MainPage.Navigation.PopAsync();

        });
    }

    protected override void OnAppearing()
    {
        base.OnAppearing();
        fotoCamera.IsScanning = true;
        fotoCamera.IsVisible = true;
    }

 


Answers (1)