我有一个基于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)