Ios navigationController在Swift上意外发现零

Ios navigationController在Swift上意外发现零,ios,swift,uiviewcontroller,uinavigationcontroller,Ios,Swift,Uiviewcontroller,Uinavigationcontroller,在展开可选值navigationcontroller时,我遇到了非常奇怪的错误,意外地发现了nil 我有两个ViewController,其主要功能是扫描条形码,并在PreBarCodeViewController的文本字段中设置值。第二个viewController是用于扫描的条形码viewController。根据透视图,用户可以手动输入值,也可以扫描获取条形码。当我去手动输入导航控制器工作良好。但一旦我点击扫描并在textField中获取值并按下ok按钮,它就不会导航了。即使我点击交叉按钮

在展开可选值navigationcontroller时,我遇到了非常奇怪的错误
,意外地发现了nil

我有两个ViewController,其主要功能是扫描条形码,并在PreBarCodeViewController的文本字段中设置值。第二个viewController是用于扫描的条形码viewController。根据透视图,用户可以手动输入值,也可以扫描获取条形码。当我去手动输入导航控制器工作良好。但一旦我点击扫描并在
textField
中获取值并按下ok按钮,它就不会导航了。即使我点击交叉按钮,它也不会给我任何错误

更新:包含条形码视图控制器,点击按钮打开

PreBarcodeViewController:返回和接受两个按钮

@IBAction func toBarcode(_ sender: Any) {
        let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let newViewController = storyBoard.instantiateViewController(withIdentifier: "BarcodeViewController") as! BarcodeViewController

        present(newViewController, animated: true, completion: nil)

    }
BarcodeViewController:当我得到返回的值时

if  url == decodedURL {

     let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
     let newViewController = storyBoard.instantiateViewController(withIdentifier: "PreBarcodeViewController") as! PreBarcodeViewController

     let str2 = String(url)
     newViewController.txtValue = str2
     present(newViewController, animated: true, completion: nil)

        }

使用
present()打开视图控制器时,使用
disclose()
方法返回上一屏幕

popViewController()

仅在使用导航控制器导航时使用。请检查此项。

如何打开
BarcodeViewController
?@dahiya_boy更新代码。单击按钮。在
BarcodeViewController
中,您需要访问您的控制器并使用委派来获取以前控制器中的选定数据。@dahiya_boy On
PreBarcodeController
我在哪里设置委派
ViewDid出现
-
barscan.delegate=self
?出现之前
BarcodeViewController
。很好,但主要是
onClickedAccept
按钮事件。
BarcodeViewController
未以可用方法显示代表分配,请检查此项。我正在检索文本字段上显示的值,然后只有当扫描执行时,它才一切正常。我在preBarCodeController中获得了值,但navigateController无法工作。
popViewController()