0

I have a custom view that contains a WebView. My custom view does its own layout in resizeWithOldSuperviewSize: then invokes resizeSubviewsWithOldSize: to resize its subviews.

My custom view contains a WebView, an NSTextField, and another custom view. The NSTextField and the custom view react very nicely to changes in size of the window, but my WebView just sits there at its original size.

EDIT: Note that the position of the WebView changes as expected but the size does not.

- (void)resizeSubviewsWithOldSize:(NSSize)oldSize
    {
    NSRect superBounds = self.superview.bounds;

    // ... set frames on other subviews; works fine ...

    // Move the WebView
    NSRect oldFrame = webView.frame;
    [self setNeedsDisplayInRect:oldFrame];
    NSRect newFrame = NSMakeRect(superBounds.origin.x, 55.0, superBounds.size.width, superBounds.size.height - 55.0);
    [webView setFrame:newFrame];

    // This doesn't work:
    // [[[[webView mainFrame] frameView] documentView] setNeedsDisplay:YES];

    // Neither does this:
    // [webView setNeedsDisplayInRect:newFrame];
    }

Any suggestions?

Craig
  • 3,253
  • 5
  • 29
  • 43

1 Answers1

0

I may have solved this myself. Turned off the "Auto Layout" feature in Interface Builder. I've never been a fan of any of the automatic layout features in IB; I prefer to do my own layout in code (easier to archive, find, change, copy, etc.). I've been working in iOS for a while and haven't run into Auto Layout before.

So none of the commented-out lines at the end of the code quoted in the question are necessary -- just set the frame.

Craig
  • 3,253
  • 5
  • 29
  • 43