Reputation: 1333
I added a WebView to my app and I'm loading a page into it using this code:
-(void)awakeFromNib{
NSString *resourcesPath = [[NSBundle mainBundle] resourcePath];
NSString *htmlPath = [resourcesPath stringByAppendingString:@"/calendarHTML/test.html"];
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:htmlPath]]];
}
However, when I run the app I receive the following error:
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.!
What is causing this problem?
Upvotes: 11
Views: 2170
Reputation: 1539
I am not sure about the case of WebView
but If you are using any custom class (like subclass of UILabel
) and you are using the method :
- (void)updateConstraints
{
}
then definitely It will crash your app. Best solution is to remove this method and write your required changes in 'awakeFromNib
' method. Hope this help someone else who is getting this crash in custom class.
Upvotes: 0
Reputation: 2667
Note that you can safely ignore that log message for WebViews.
Upvotes: 3
Reputation: 46020
This is caused by the fact that the nib containing the window that you have placed the WebView into is using the new Auto Layout feature, introduced in Lion.
When a nib file has auto layout enabled, the window will call the -layout
method on all NSView
objects in the window.
This causes a problem with WebView
because it had a method named -layout
before it the method was added to the NSView
API in Lion, and WebView
's layout
method does not understand auto layout.
Probably the best fix for the time being is to use the old autoresizing mask method of laying out the views in your window. As Xcode now creates nib files with autolayout enabled, you need to disable it yourself.
You can do that in the File inspector for your nib file, by disabling the Use Auto Layout
checkbox.
After you do this, you'll need to make sure that all the views in the nib have the correct autoresizing settings in the Size tab of the view inspector.
Upvotes: 12