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
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;
}
Add in the app delegate this line ZXing.Net.Mobile.Forms.iOS.Platform.Init();
before LoadApplication(new App());
and ready ...