iOS12:transitionController 已弃用

iOS12: transitionController was deprecated

我有一个基于 UIDocumentBrowser 的应用程序,它可以打开特定类型的文件。打开文件的默认过渡是从底部滑动,这不是用户可以期望的最好的过渡。在 iOS 12 之前,您可以获得缩放过渡,它现在也可以工作,但编译器抱怨使用 transitionController(forDocumentURL:) 已弃用。我怎样才能在 iOS 12 路中获得这种效果?

func presentDocument(at documentURL: URL) {
    let storyBoard = UIStoryboard(name: "Main", bundle: nil)
    let documentViewController = storyBoard.instantiateViewController(withIdentifier: "MainViewController") as! MainViewController
    documentViewController.document = Document(fileURL: documentURL)
    // 
    documentViewController.transitioningDelegate = self
    let transitioningController = transitionController(forDocumentURL: documentURL)
    transitioningController.targetView = documentViewController.view
    self.transitioningController = transitioningController
    //
    present(documentViewController, animated: true, completion: nil)
}

我相信参数刚刚更改,您可以将 forDocumentURL 替换为 forDocumentAt:

let transitioningController = transitionController(forDocumentAt: documentURL)