【发布时间】:2016-08-17 11:06:57
【问题描述】:
我正在尝试将条形码扫描仪功能添加到我的 xamarin.ios 应用程序。我是从 Visual Studio 开发的,我已经从 xamarin 组件商店添加了 Zxing.Net.Mobile 组件。
我已经按照示例所示实现了它:
ScanButton.TouchUpInside += async (sender, e) => {
//var options = new ZXing.Mobile.MobileBarcodeScanningOptions();
//options.AutoRotate = false;
//options.PossibleFormats = new List<ZXing.BarcodeFormat>() {
// ZXing.BarcodeFormat.EAN_8, ZXing.BarcodeFormat.EAN_13
//};
var scanner = new ZXing.Mobile.MobileBarcodeScanner(this);
//scanner.TopText = "Hold camera up to barcode to scan";
//scanner.BottomText = "Barcode will automatically scan";
//scanner.UseCustomOverlay = false;
scanner.FlashButtonText = "Flash";
scanner.CancelButtonText = "Cancel";
scanner.Torch(true);
scanner.AutoFocus();
var result = await scanner.Scan(true);
HandleScanResult(result);
};
void HandleScanResult(ZXing.Result result)
{
if (result != null && !string.IsNullOrEmpty(result.Text))
TextField.Text = result.Text;
}
问题是,当我点击扫描按钮时,捕获视图正确显示,但如果我尝试捕获条形码,则没有任何反应,并且扫描仪似乎无法识别任何条形码。
有人遇到过这个问题吗?我怎样才能让它工作?
提前感谢您的帮助!
【问题讨论】:
-
你在这里试过吗? components.xamarin.com/gettingstarted/zxing.net.mobile有一个示例代码(我从来没有使用过条码扫描器)
-
是的,我遵循了该示例代码,但它不起作用。我还尝试从 github repo 运行 ios 示例,但它也不起作用。可能是我的ipad 2的问题(我用这个来测试)?
-
你能关注这个吗? blog.xamarin.com/…
-
不幸的是,它与 xamarin 形式有关。我需要 che ios 版本 :(
标签: ios xamarin xamarin.ios zxing barcode-scanner