ios – MonoTouch,ZXing:呈现ZXingScannerViewController失败

前端之家收集整理的这篇文章主要介绍了ios – MonoTouch,ZXing:呈现ZXingScannerViewController失败前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
因此,在我的应用程序开始时,用户必须能够扫描QR码.在应用程序设置中,用户可以扫描另一个条形码以更改设置中的某些数据.

在我的应用程序开始扫描仪工作正常,但当我尝试扫描settingsVC中的条形码时,我得到以下警告:

Warning: Attempt to present ZXing.Mobile.ZXingScannerViewController: 0x18036dc0 on UINavigationController: 0x16d8afe0 whose view is not in the window hierarchy!

我已经尝试在viewDidAppear上调用扫描,但是我得到了相同的警告.

button_ScanAPI.TouchUpInside += async (sender,e) => {
                var scanner = new ZXing.Mobile.MobileBarcodeScanner ();
                var result = await scanner.Scan ();

                if (result != null) {
                    textField_APIKey.Text = result.Text;
                }   
            };

编辑:

试图使用没有异步的条形码扫描仪,但我仍然得到相同的消息.

var scanner = new ZXing.Mobile.MobileBarcodeScanner ();
                scanner.Scan (true).ContinueWith (t => {   
                    if (t.Result != null) {

                        InvokeOnMainThread (() => {
                            textField_APIKey.Text = t.Result.Text;

                        });
                    }
                });

我也尝试使用AVFoundation导致同样的错误

Warning: Attempt to present <AVCaptureScannerViewController: 0x16fb1d00> on <UINavigationController: 0x16ebe790> whose view is not in the window hierarchy!

EDIT2:

这是我的应用程序中的流程的一部分.

解决方法

@H_502_27@ 因此,您可以本地扫描QR.在iOS 7中,AVFoundation能够扫描QR.
看看 doc.

here有一个使用Xamarin的例子.

原文链接:https://www.f2er.com/iOS/328364.html

猜你在找的iOS相关文章