swift - iOS12 : transitionController was deprecated

标签 swift viewcontroller

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

关于swift - iOS12 : transitionController was deprecated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55146930/

相关文章:

iOS - 将 subview 添加到 subview Controller View

ios - 如何从 appDelegate 访问每个 ViewController?

ios - Swift 3 打开链接

iOS 10.2 - 使用手电筒激活 Retina Flash 而不是 Back LED

Swift-设置uitextview文本压缩文本大小

ios - 如何发布 One Signal 通知的附加数据并接收这些数据?

json - 使用 Swift JSON 从 TheMovieDB API 获取数据时遇到问题

ios - 获取使用 Storyboard创建的 View Controller 的属性

ios - 激活 iPhone 相机操作使我的应用程序崩溃

ios - didBarButton.enabled 带有 && 语句