我将QLPreviewController作为子视图添加到我的QLPreviewControllerWithDownloadView。
然后当我展示我的QLPreviewControllerWithDownloadView并让它预览图像时,如果在图像上检测到任何平移,我的QLPreviewControllerWithDownloadView视图会立即被解除。
关于如何阻止视图解除阻力的任何想法?
答案 0 :(得分:0)
我通过颠倒我的想法来解决这个问题。我没有将QLPreviewController作为子视图添加,而是将QLPreviewController子类化,并将我的下载视图添加为子视图。
class QuickLookViewController: QLPreviewController {
//Download View Properties
var downloadViewController: DownloadFileViewController?
// MARK: - Application Life Cycle
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
guard let downloadView = self.downloadViewController?.view else { return }
view.bringSubview(toFront: downloadView)
}
override func viewDidLoad() {
super.viewDidLoad()
addDownloadViewIfNeeded()
downloadAndPreview()
}
// MARK: - Private
private func addDownloadViewIfNeeded() {
guard self.downloadViewController == nil else { return }
let downloadViewController = DownloadFileViewController.viewControllerFromStoryboard()
downloadViewController.view.isHidden = true
downloadViewController.delegate = self
addChildViewController(downloadViewController)
view.addSubview(downloadViewController.view)
downloadViewController.view.pinFrameToSuperViewBounds()
downloadViewController.didMove(toParentViewController: self)
self.downloadViewController = downloadViewController
}
...
}