我将这个库用于我的 Xamarin.Forms 应用程序:https ://github.com/Redth/ZXing.Net.Mobile
刚开始,它可以在 Android 上完美运行。iOS 显示相机取景器,但它无法识别任何条形码。
我根据需要在我的 AppDelegate 中初始化它:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
ZXing.Net.Mobile.Forms.iOS.Platform.Init();
LoadApplication(new App(new iOSInitializer()));
return base.FinishedLaunching(app, options);
}
我还在 Info.plist 中设置了权限描述:
<key>NSCameraUsageDescription</key>
<string>Please allow access to the camera to scan barcodes</string>
但我想这很明显,否则相机取景器也不起作用。