UIDocumentPickerViewController选取文件后无法继续present/push另外一个界面处理

页面结构为
TabBarController 》

//A 方法的作用是调用icloud选取文件
func A(){
  let picker = UIDocumentPickerViewController.init(documentTypes: ["public.data"], in: .import)
    pickerd.delegate = self
    self.present(picker, animated: true, completion: nil)
}

// documentPicker方法是pickerd.delegate回调的方法
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
    // 这里用通知是我原认为这个地方已经是处于present的模态窗口中,不能继续present,因为这个UIDocumentPickerViewController选取文件后会自己自动关闭,所以想着通知在另外一个地方中处理
      NotificationCenter.default.post(name: NSNotification.Name("selected"), object: self, userInfo:["urls": urls])
}

//selected方法是为了选取到icloud中文件后,想继续打开另外一个viewcontroller进行处理
@objc func selected(notification:NSNotification) {
    let userInfo = notification.userInfo

        guard let url = userInfo?["urls"] as? [URL] else {
            return
        }
        controllerB.url = url
   self.present(controllerB,animated: true, completion: nil))
}

现在的问题是,回调selected方法后, self.present 会提示Application tried to present modally an active controller,我想会不会是因为seleted方法也在TabBarController文件中,才会报错,但是事实上好像也不是这样,我也试过在A方法中再加一层navigationController,在seleted中用这个navigationController实例再做push,试验证明push是没报错,但是页面也并不会发生跳转,实在无解,求教。难道不能在UIDocumentPickerViewController拾取文件后再处理

你可以试试 notification 的 addObserver 方法 接收了通知 自定义的传值

我是我在通知里面进行处理的,能接到传值,但是在present的时候提示Application tried to present modally an active controller