Generate QR code with Xamarin.Forms and Zxing

前端 未结 2 758
小鲜肉
小鲜肉 2021-02-14 09:31

I\'ve seen alot about this online (old posts) but nothing seems to work for me. I\'m trying to generate a QR code out of a string and display it in the app.

Here\'s what

相关标签:
2条回答
  • 2021-02-14 09:57

    It seems to be a known issue.
    Luckily there is a workaround, to set a HeightRequest & WidthRequest, here is a working code example:

    ZXingBarcodeImageView GenerateQR(string codeValue)
    {
        var qrCode = new ZXingBarcodeImageView
        {
            BarcodeFormat = BarcodeFormat.QR_CODE,
            BarcodeOptions = new QrCodeEncodingOptions
            {
                Height = 350,
                Width = 350
            },
            BarcodeValue = codeValue,
            VerticalOptions = LayoutOptions.CenterAndExpand,
            HorizontalOptions = LayoutOptions.CenterAndExpand
        };
        // Workaround for iOS
        qrCode.WidthRequest = 350;
        qrCode.HeightRequest = 350;
        return qrCode;
    }
    
    0 讨论(0)
  • 2021-02-14 10:16

    Add in the app delegate this line ZXing.Net.Mobile.Forms.iOS.Platform.Init();

    before LoadApplication(new App());

    and ready ...

    0 讨论(0)
提交回复
热议问题