问题描述
我试图制作一个使用Xamarin和ZXing读取涉及网站地址的二维码的应用程序,并在成功读取二维码后打开浏览器中的链接。但是我的问题是:在浏览器中打开链接并返回到QR阅读器应用程序后(通过后退按钮或使用主页按钮关闭浏览器),我的应用程序无法再阅读其他QR码。(“阅读QR文件一旦通过浏览器进入网站,返回浏览器并继续阅读qr并打开它们”是我试图达到的目标
到目前为止我尝试过的是什么
- 创建一个按钮,将其单击时将scanView.IsScanning设置为true。结果:在第一个qr并在浏览器中打开后,它仍然不读取另一个qr
- 使用onDisappearing和onAppearing将scanView.IsScanning更改为true,以便可以再次读取
- 在App.xml中“ MainPage = new MainPage();”将此代码行添加到onResume和onSleep,但是这种方法基本上是从头开始打开应用程序,对于较旧的设备来说太费力了,并且需要一些时间
- 试图从其他人的qr问题中寻找解决方案,但是到目前为止,我一直没有找到/找不到解决方案
我如何使qr阅读器在读取一次并对其采取行动后才能读取另一张qr。预先感谢
ps:我关注了Redth的github文件以及其他实现此问题的人
mainpage.xaml.cs中的代码
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
public void scanView_OnScanResult(ZXing.Result result)
{
if (result.Text != null && result.Text.Contains("ramakbilisim"))
{
Browser.OpenAsync(result.Text,BrowserLaunchMode.SystemPreferred);
}
}
protected override void OnAppearing()
{
base.OnAppearing();
scanView.IsScanning = true;
}
protected override void OnDisappearing()
{
base.OnDisappearing();
scanView.IsScanning = false;
}
}
mainpage.xaml中的代码
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:zxing="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"
mc:Ignorable="d"
x:Class="RamakDenemeQr.MainPage">
<StackLayout Padding="0,10">
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
<Label Text="Ramak Deneme Qr" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>
</Frame>
<zxing:ZXingScannerView
x:Name="scanView"
OnScanResult="scanView_OnScanResult"
IsScanning="False"
WidthRequest="300"
HeightRequest="400"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
/>
</StackLayout>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)