2014-11-22 62 views
0

我试图在QuickLook插件中显示HTML。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 

回答

0

我有没有调试也不在Finder中运行调试版本将工作同样的问题。不过,我观察到,如果我构建了“For Running”插件,那么它在Finder中工作得很好。

-1

我与'kUTTypeHTML'内容类型UTI具有相同的确切问题。我无法用Xcode进行调试,但部署的插件在Finder中正常工作。 我认为它开始发生在小牛队,后来,能够在旧版本的OS X和Xcode上进行调试。

0

kUTTypeHTML预览在Yosemite中修复10.10.3