MonoTouch,ZXing:呈现ZXingScannerViewController失败

 新起点新娘妆 发布于 2023-02-08 16:29

因此,在我的应用程序开始时,用户必须能够扫描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  on  whose view is not in the window hierarchy!

EDIT2:

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

在此输入图像描述

1 个回答
  • 我认为默认情况下,ZXing库必须寻找最顶级的NavigationController并尝试从那里呈现模态视图控制器.和你一样,我已经在根目录的顶部模拟地呈现了另一个NavigationController.我能够通过将构造函数更改为:

    var scanner = new MobileBarcodeScanner (this);
    var result = await scanner.Scan ();
    

    其中"this"是您实际调用扫描程序的ViewController.

    2023-02-08 16:30 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有