Mac OS X中的Autolayout警告

时间:2012-03-31 18:35:58

标签: macos cocoa webview autolayout

我每次运行应用程序时都会收到警告:

Layout still needs update after calling -[WebHTMLView layout]. WebHTMLView or one of its superclasses may have overridden -layout without calling super. Or, something may have dirtied layout in the middle of updating it. Both are programming errors in Cocoa Autolayout. The former is pretty likely to arise if some pre-Cocoa Autolayout class had a method called layout, but it should be fixed.

(我已经看到了这个related question,但提供的答案解决了其他问题,因此我的问题。)一旦我向我的应用添加网页视图,就会出现警告。这是什么意思,我该如何解决这个问题呢?

2 个答案:

答案 0 :(得分:3)

似乎在- (void)layout中实施了WebHTMLView。 WebKit的源代码可在Apple的开源页面上查看。

http://www.opensource.apple.com/source/WebKit/WebKit-7534.53.11/mac/WebView/WebHTMLView.mm

在自动布局文档中,它指出如果在使用自动布局时需要自定义逻辑来布局子视图,则只需要实现“布局”。接着说,您应该始终在自定义实现中调用[super layout]WebHTMLView没有发生这种情况。

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html%23//apple_ref/occ/instm/NSView/layout

此消息可能可以安全地忽略您的项目。在一个空白的新项目中,同样的事情发生在我身上。

答案 1 :(得分:0)

除了标注NSTableView拖动之外,我发现如果您打开NSFontManager,这将始终显示此消息。不仅使用Swift,还使用Apple自己的演示程序CoreTextArcCocoa。所以它肯定是Apple的胆量中的一些错误。