Redth / ZXing.Net.Mobile

Barcode Scanner for Xamarin.iOS, Xamarin.Android, UWP and Tizen
MIT License
1.07k stars 703 forks source link

Xamarin forms zxing ZXingScannerView not working on ios #434

Closed whitelapu closed 4 years ago

whitelapu commented 8 years ago

I am writing a mobile app in xamarin forms and I have half the screen continuously scanning barcodes using ZXingScannerView. This works great in android however in ios it will not pick up any barcodes using ZXingScannerView. However ios does pick up barcodes using the full page ZXingScannerPage. In my example code below the method Scanner_OnScanResult is never getting hit. How can I get this to work in ios am i missing something?

ZXingScannerView scanner = new ZXingScannerView
        {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.FillAndExpand,
            AutomationId = "zxingScannerView",
            IsScanning = true,
            Options = new ZXing.Mobile.MobileBarcodeScanningOptions
            {
            UseFrontCameraIfAvailable = false,//update later to come from settings
            PossibleFormats = new List<ZXing.BarcodeFormat>(),
            TryHarder = true
            }
        }
 ZXingDefaultOverlay overlay = new ZXingDefaultOverlay();
 scanner.Options.PossibleFormats.Add(ZXing.BarcodeFormat.QR_CODE);
 scanner.OnScanResult += Scanner_OnScanResult;
 private void Scanner_OnScanResult(ZXing.Result result)
        {
            DisplayAlert("Exit", "TEST", "Yes", "No");
        }
whitelapu commented 8 years ago

This has been resolved.

IsAnalyzing must be set to true manually when working in a view

futurify-nhatho commented 7 years ago

Great thanks @whitelapu, couldn't figure out why the camera didn't show up. Phew now I know.

TonyC5 commented 6 years ago

@whitelapu - thank you. Still good advice with ZXing.Net.Mobile.Forms.2.3.2. I added IsAnalyzing = true; to OnAppearing().

FreedCapybara commented 6 years ago

My problem was that I needed HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand

Anoop1 commented 6 years ago

Hi whitelapu , did you manage to get the scan to work? im new to the mobile dev and have a similar requirement... would you mind sharing some of your code/xaml so i can get the basic up and running

thanks

Redth commented 4 years ago

Thanks for reporting this issue! Unforunately it took me way too long to respond 😭. Sorry, I apologize! Recently the source code for this project was completely refactored to modernize it. Many PR's were included in this effort, and many bugs were hopefully fixed. Please try out the latest 3.x series of NuGet packages (currently in prerelease). To try and make the project more maintainable in my spare time going forward, I've decided to close all existing issues to start with a clean slate. If you're still experiencing this issue on the newest version, please open a new issue with as much detail as possible. Thank you for your patience and understanding! Happy scanning!