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>
推荐阅读
- java - 我应该如何在 Google Play 管理中心启用我的 AdMob 真实 ID?
- xamarin.forms - 有没有办法在 Xamarin Forms 中使用相机功能而无需下载任何额外的 NuGet 包?
- java - Spring Boot 应用程序未在外部 Tomcat 中启动(在 Tomcat 8.5 和 10 中均已尝试)
- canvas - 如何在画布中旋转渐变,注意:不是画布本身
- docker - 在同一个 Docker 网络中发出 HTTP 请求
- arm - 用于高速微控制器测试台控制器/数据采集器的系统架构
- azure - 从 Azure DevOps 设置应用服务连接字符串
- c# - 等待 for 循环完成
- python - 更新烧瓶中的搜索数据后保持在同一页面上
- r - 绘制免疫表型图:暗示不同数量 rof 行错误的参数