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:

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

解决方法

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

here有一个使用Xamarin的例子.

以上是来客网为你收集整理的ios – MonoTouch,ZXing:呈现ZXingScannerViewController失败全部内容,希望文章能够帮你解决ios – MonoTouch,ZXing:呈现ZXingScannerViewController失败所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。