微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ZXing 二维码扫描器 Xamarin

如何解决ZXing 二维码扫描器 Xamarin

我尝试实现包 ZXing.Net.Mobile.Forms

这是我的 xaml:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:zxing="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"
         Title="{Binding Title}">

<ContentPage.Content>
    <StackLayout>
        <Label x:Name="scanResultText" />
        <zxing:ZXingScannerView 
            OnScanResult="ScanViewOnScanResult"/>
    </StackLayout>
</ContentPage.Content>

这是我的 xaml.cs :

public partial class QRCodePage : ContentPage
{

    public QRCodePage()
    {
        InitializeComponent();

        BindingContext = new QRCodeviewmodel();
    }

    public void ScanViewOnScanResult(Result result)
    {
        Device.BeginInvokeOnMainThread(async () =>
        {
            scanResultText.Text = result.Text;
        });
    }
}

在我的设备上我可视化了片段,但它似乎没有扫描

解决方法

尝试将以下代码 (IsScanning="True") 添加到您的 xaml:

<StackLayout>
    <Label x:Name="scanResultText" />
    <zxing:ZXingScannerView IsScanning="True"
        OnScanResult="ScanViewOnScanResult"/>
</StackLayout>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。