Stefano Stefano - 1 year ago 273
iOS Question

Xamarin.Forms ZXing.Net.Mobile loosing current page after scan result on iOS 10

I'm using Xamarin.Forms and I have implemented ZXing.Net.Mobile for scanning bar codes.

On Android it's working fine, on iOS 10 after reading a barcode the function "OnScanResult" is fired and executes the command Navigation.PopAsync() which closes the scanning page but after a second it closes also the current page where I have displayed the result !

MyTapScan.Tapped += async (sender, e) =>
await MyBtScan.ScaleTo(1.20, 100, Easing.Linear);
await MyBtScan.ScaleTo(1, 100, Easing.Linear);
await Task.Delay(50);
MyAppLib.MyAppUtilitiesBarCodeReader MyBarCodeReader = new MyAppLib.MyAppUtilitiesBarCodeReader();
var MyScannerPage = MyBarCodeReader.GetBarCodeReaderPage();
MyScannerPage.OnScanResult += (result) => {
//Stop scanning
MyScannerPage.IsScanning = false;
//Pop the page and show the result
Device.BeginInvokeOnMainThread(() => {
MyMachSerialNumber.Text = result.Text;
//Display scanner
await Navigation.PushAsync(MyScannerPage);

Please please help..!! :)

Answer Source

Every time MyTapScan.Tapped is called you are subscribing to MyScannerPage.OnScanResult so if you tap button 5 times your OnScanResult will be called 5 times. I hope now you know how to solve that.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download