views:

217

answers:

2

So I have a project that has some content being displayed in a WebView and I want to stick above that. I want the header to scroll with the WebView content. Now, WebView generally wants to do it's own scroll handling but you can tell it not to using:

[[webView mainFrame] setAllowsScrolling:NO];

which successfully makes the WebView's scroll bars not appear. However, despite the fact that it's embedded in an NSScrollView, the NSScrollView's scroll bars never activate. I can only conclude that the WebView needs to be told to resize, but I can't figure out how to do that. I have tried the following:

NSRect webViewBounds = [webView bounds];
[webView setFrameSize:webViewBounds.size];

but that doesn't appear to work either.

Any suggestions?

A: 

I had a quick look at the docs for this, probably a silly question; after you change the frame size are you sending a setNeedsDisplay message to the view?

Abizern
Yes, I am. No difference. I suspect the problem may be that the WebView is sizing based on the size I gave it in Interface Builder. I'm not sure how to tell it it can be as big as it wants, nor how to find out how big it could be given the content. I might just try giving it a huge vertical size and see how it goes.
Benno
A: 

Alternative solution: What about expressing the header in HTML/CSS/JavaScript, and putting the real content in an iframe? You can traverse the frame hierarchy to find the WebFrame object for that frame, and use the DOM (perhaps wrapped by an object of your own) to control the header.

Peter Hosey
Yeah, I was thinking of trying that. Seems like a kludge but if that's what it takes... =)
Benno