【问题标题】:Xamarin iOS Zxing with ZXingScannerViewXamarin iOS Zxing 与 ZXingScannerView
【发布时间】:2017-10-28 14:00:05
【问题描述】:

扫描完成后需要导航到其他视图
将 Zxing 与 ZXingScannerView 一起使用

使用此代码

scannerView.StartScanning(async (result) =>
{
    if (!ContinuousScanning)
    {
        Console.WriteLine("Stopping scan...");
        Console.WriteLine("Result: " + result.Text);
        scannerView.StopScanning();
        if (result != null)
        {
            await GetScannedDetails(result.Text);
            // here i need to navigate to other screen
        }
    }

    var evt = this.OnScannedResult;
    if (evt != null) evt(result);
}, this.ScanningOptions);


当我尝试导航时出现此错误
一致性错误:您正在调用只能从 UI 线程调用的 UIKit 方法。

【问题讨论】:

  • 您是否阅读过有关导航的文档?
  • @Jason,我知道使用导航控制器,但我在尝试时出错。我已经更新了我的问题。
  • 如果您搜索该错误消息,您将获得一些有用的提示

标签: xamarin.ios navigation zxing


【解决方案1】:

您遇到的问题是,您尝试在异步任务中运行与 UI 相关的代码。在主线程内进行导航

            BeginInvokeOnMainThread(
                () =>
                {
                    scannerView.StopScanning();
                    // Navigate code goes here
                });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-31
    • 2018-05-13
    相关资源
    最近更新 更多