简体   繁体   English

Quicklook始终显示“无文件可预览”错误(URL有效)

[英]Quicklook always displays “no file to preview” error (url is valid)

I'm trying to use QuickLookController subclass as a child controller, setting its view as a subview in the parent. 我试图将QuickLookController子类用作子控制器,将其视图设置为父视图中的子视图。 However, it always displays "no file to preview" message in the opening window. 但是,它始终在打开的窗口中显示“无文件可预览”消息。 URL in the data source is valid, but the controller is never trying to get it! 数据源中的URL有效,但是控制器从未尝试获取它! func previewItemAt index is never invoked! func previewItemAt索引永远不会被调用!
func "numberOfPreviewItems" invokes always. func "numberOfPreviewItems"总是调用。
Please, help! 请帮忙!

I get it. 我知道了。 driven by example in article https://williamboles.me/hosting-viewcontrollers-in-cells/ I loaded my controller from bundle: 由文章https://williamboles.me/hosting-viewcontrollers-in-cells/中的示例驱动,我从捆绑包中加载了控制器:

static func createFromStoryBoard() -> PreviewControler {
    let storyboard = UIStoryboard(name: "PreviewControler", bundle: Bundle(for: PreviewControler.self))
    guard let viewController = storyboard.instantiateViewController(withIdentifier: "PreviewControler") as? PreviewControler else {
        fatalError("PreviewControler should be present in storyboard")
    }
    return viewController
}

But QuickLook controller must be created with it's constructor, so change to 但是QuickLook控制器必须使用其构造函数创建,因此将其更改为

let viewController = PreviewController()

solved the problem. 解决了问题。 Now all is fine. 现在一切都很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM