0

我将 ZXing.Net.Mobile、ZXing.Net.Mobile.Forms 添加到项目中。这是代码:

using ZXing.Net.Mobile.Forms;
using ZXing.Net.Mobile;

namespace discountapp
{
    public partial class discountappPage : ContentPage
    {

    ZXingBarcodeImageView barcode;

    public void Handle_Clicked(object sender, System.EventArgs e)
    {
            barcode = new ZXingBarcodeImageView
             {
                 HorizontalOptions = LayoutOptions.Center,
                 VerticalOptions = LayoutOptions.Center
             };
            barcode.BarcodeFormat = ZXing.BarcodeFormat.EAN_13;
            barcode.BarcodeOptions.Height = 25;
            barcode.BarcodeOptions.Width = 75;
            barcode.BarcodeValue = "2800100028014";
            Content = barcode;
    }
    }
}

对于 iOS 平台,还要添加 ZXing.Net.Mobile、ZXing.Net.Mobile.Forms 并在 AppDelegate 的 FinishedLaunching() 实现中进行一些更改:

global::ZXing.Net.Mobile.Forms.iOS.Platform.Init();

Android 平台还添加 ZXing.Net.Mobile、ZXing.Net.Mobile.Forms 并对 MainActivity 的 OnCreate() 方法进行一些更改:

global::ZXing.Net.Mobile.Forms.Android.Platform.Init();

但是在我点击按钮后,它没有显示条形码,只是没有错误。你能帮忙吗,拜托!

4

1 回答 1

0

ZXing repo 上的这个 issue建议添加

WidthRequest = 410,
HeightRequest = 410,

到 ZXingBarcodeImageView ,它使条形码出现,尽管纵横比不好。

于 2018-01-04T04:20:06.487 回答