Open cissemy opened 4 years ago
Same issue. Mine crashes after a barcode is scanned on iOS. Device tested: iPhone 11 Pro Max 13.4.1
Fixed my issue by changing my result handler:
public void Handle_OnScanResult(Result result)
{
BarcodeScanView.IsScanning = false;
Device.BeginInvokeOnMainThread(async () =>
{
if (string.IsNullOrWhiteSpace(result.Text))
return;
// handle result
}
}
It is the same as this one but still it does not work : private async void Scan_Clicked(object sender, EventArgs e) { var scanPage = new ZXingScannerPage(); scanPage.Title = "Scanner"; scanPage.OnScanResult += result => { scanPage.IsScanning = false;
Device.BeginInvokeOnMainThread(async () =>
{
await Navigation.PopAsync();
if (string.IsNullOrWhiteSpace(result.Text))
await DisplayAlert("Scanned Barcode", result.Text, "OK");
// mycode.Text = result.Text;
});
};
await Navigation.PushAsync(scanPage);
}
@cissemy what version of ZXing.Net.Mobile are you using?
Have anyone get ZXing.Net.Mobile scanner to work? I tried every which way possible and still, it doesn't scan on both Android or iOS device. I am using the latest version of Xamarin.Forms 5.0.x.x and latest ZXing.Net.Mobile package. Any help is greatly apprecitated.
Here is my code : public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); } private async void Scan_Clicked(object sender, EventArgs e) {
} } In AppDeletegate.cs : public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); ZXing.Net.Mobile.Forms.iOS.Platform.Init(); LoadApplication(new App());
Thanks