【问题标题】:QuickLook plugin fails to display HTMLQuickLook 插件无法显示 HTML
【发布时间】:2014-11-22 13:28:34
【问题描述】:

我正在尝试在 QuickLook 插件中显示 HTML。

GeneratePreviewForURL方法:

...

NSMutableString *html=[[NSMutableString alloc] init];

[html appendString:@"<html>"];
[html appendString:@"<body>"];
[html appendString:@"<h1>First Last</h1>"];
[html appendString:@"</body>"];
[html appendString:@"</html>"];

QLPreviewRequestSetDataRepresentation(
  preview,
  (__bridge CFDataRef)[html dataUsingEncoding:NSUTF8StringEncoding],
  kUTTypePlainText,
  NULL
);

...

预览窗口将 HTML 显示为纯文本:

<html><body><h1>First Last</h1></body></html>

但是,当我切换到 HTML 时:

...

NSDictionary *properties = @{
  (__bridge NSString *)kQLPreviewPropertyTextEncodingNameKey : @"UTF-8",
  (__bridge NSString *)kQLPreviewPropertyMIMETypeKey : @"text/html"
};

QLPreviewRequestSetDataRepresentation(
  preview,
  (__bridge CFDataRef)[html dataUsingEncoding:NSUTF8StringEncoding],
  kUTTypeHTML,
  (__bridge CFDictionaryRef)properties
);

...

** 编辑**

在调试模式下不显示预览窗口,但是,选择联系人(例如从 Spotlight 中)将显示预览。

** / 编辑 **

最终,我收到了警告(如下所列)。

我错过了什么?为什么预览版的工作方式与编译后的代码不同?

追踪:

Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const: conn 0x32807 token 0x1ffffffffffe85
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: Backtrace (at 118686):
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  0   CoreGraphics                        0x00007fff913f9215 CGSBacktraceCreate + 59
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  1   CoreGraphics                        0x00007fff91418688 _ZN16CGSUpdateManager14disable_updateEv + 84
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  2   AppKit                              0x00007fff8738ede5 -[NSWindow disableScreenUpdatesUntilFlush] + 127
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  3   AppKit                              0x00007fff878c394d -[NSVisualEffectView _createOrUpdateBackdrop:view:vibrancyEffect:] + 823
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  4   AppKit                              0x00007fff878c466a -[NSVisualEffectView _updateCGSWindowBackdrop] + 70
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  5   AppKit                              0x00007fff878c8294 -[NSVisualEffectView _update] + 147
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  6   AppKit                              0x00007fff878c7fc1 -[NSVisualEffectView layout] + 59
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  7   AppKit                              0x00007fff87370f54 -[NSView _layoutSubtreeWithOldSize:] + 373
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  8   AppKit                              0x00007fff873711a5 -[NSView _layoutSubtreeWithOldSize:] + 966
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  9   AppKit                              0x00007fff87364970 -[NSView layoutSubtreeIfNeeded] + 885
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  10  AppKit                              0x00007fff879e0e7a _NSViewLayoutSubtreesThatUseAutolayoutIfNeeded + 71
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  11  AppKit                              0x00007fff873c5b0f -[NSWindow(NSConstraintBasedLayout) _layoutViewTree] + 82
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  12  AppKit                              0x00007fff873f5569 -[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 244
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  13  AppKit                              0x00007fff8743162e _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 612
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  14  AppKit                              0x00007fff879f6cf1 __83-[NSWindow _postWindowNeedsDisplayOrLayoutOrUpdateConstraintsUnlessPostingDisabled]_block_invoke1523 + 46
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  15  CoreFoundation                      0x00007fff923acd87 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  16  CoreFoundation                      0x00007fff923acce0 __CFRunLoopDoObservers + 368
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  17  CoreFoundation                      0x00007fff9239ede8 __CFRunLoopRun + 872
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  18  CoreFoundation                      0x00007fff9239e838 CFRunLoopRunSpecific + 296
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  19  QuickLookUI                         0x00007fff84d2b50b -[QLPreviewView _startTimeOut] + 189
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  20  QuickLookUI                         0x00007fff84d0e1e1 -[QLPreviewPanelController _setCurrentPreviewItem:withTransition:blocking:] + 289
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  21  QuickLookUI                         0x00007fff84d0d916 -[QLPreviewPanelController _refreshLayoutAndContentBlocking:] + 250
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  22  QuickLookUI                         0x00007fff84d0efbc -[QLPreviewPanelController willOpen] + 734
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  23  QuickLookUI                         0x00007fff84d0612c -[QLPreviewPanel _openWithEffect:willOpen:toFullscreen:] + 945
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  24  qlmanage                            0x00000001000253b2 qlmanage + 152498
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  25  qlmanage                            0x0000000100004a8f qlmanage + 19087
Nov 22 07:16:01 Pippin.local qlmanage[46393] <Warning>: void CGSUpdateManager::log() const:  26  libdyld.dylib                       0x00007fff8d7ad5c9 start + 1

【问题讨论】:

    标签: objective-c xcode xcode6 quicklook


    【解决方案1】:

    我有同样的问题,无论是在 Finder 中调试还是运行调试版本都不起作用。但是,我观察到如果我构建了“For Running”插件,那么它在 Finder 中就可以正常工作。

    【讨论】:

      【解决方案2】:

      我对“kUTTypeHTML”内容类型 UTI 有同样的问题。我无法使用 Xcode 进行调试,但部署的插件在 Finder 中正常工作。 我认为它开始在 Mavericks 上发生,后来能够在旧版本的 OS X 和 Xcode 上正常调试。

      【讨论】:

        【解决方案3】:

        在 Yosemite 10.10.3 中修复了 kUTTypeHTML 预览

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-10-24
          • 2017-09-22
          • 2013-04-11
          相关资源
          最近更新 更多