我将 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();
但是在我点击按钮后,它没有显示条形码,只是没有错误。你能帮忙吗,拜托!