微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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的例子.

原文地址:https://www.jb51.cc/iOS/328364.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐