scrolling content view resizes visibly but bounds and frame don't change
scrolling content view resizes visibly but bounds and frame don't change
- Subject: scrolling content view resizes visibly but bounds and frame don't change
- From: Christopher Corbell <email@hidden>
- Date: Thu, 9 Sep 2010 00:20:52 -0700
This one is really bugging me. I have a WebView in a scrolling view and
content gets appended to it periodically (new tables appended; the entire
content of the WebView is reset each time via loadHTMLString on the
mainFrame).
VIsually, the webView correctly expands to include new content including
proper updating of the scrollbars; it looks fine and you can scroll up and
down the document as it grows.
The problem is that in code the bounds and frames of all views involved
never change to reflect the larger content of the webView. This means that
I can't make the view scroll to the bottom programmatically when new content
is appended which is what I want.
To make extra sure, I hooked up a lot of logging as follows; the output
never changes even when the content is clearly scrolling offscreen.
std::stringstream ssDbg;
NSRect docFrame = [[scrollView documentView] frame];
NSRect docBounds = [[scrollView documentView] bounds];
NSRect webFrame = [webView frame];
NSRect webBounds = [webView bounds];
NSRect contentFrame = [[scrollView contentView] frame];
NSRect contentBounds = [[scrollView contentView] bounds];
NSSize contentSize = [scrollView contentSize];
ssDbg << "\ndocFrame: (" << docFrame.origin.x << "," <<
docFrame.origin.y << ") " << docFrame.size.width << " x " <<
docFrame.size.height << std::endl;
ssDbg << "docBounds: (" << docBounds.origin.x << "," <<
docBounds.origin.y << ") " << docBounds.size.width << " x " <<
docBounds.size.height << std::endl;
ssDbg << "webFrame: (" << webFrame.origin.x << "," << webFrame.origin.y
<< ") " << webFrame.size.width << " x " << webFrame.size.height <<
std::endl;
ssDbg << "webBounds: (" << webBounds.origin.x << "," <<
webBounds.origin.y << ") " << webBounds.size.width << " x " <<
webBounds.size.height << std::endl;
ssDbg << "contentFrame: (" << contentFrame.origin.x << "," <<
contentFrame.origin.y << ") " << contentFrame.size.width << " x " <<
contentFrame.size.height << std::endl;
ssDbg << "contentBounds: (" << contentBounds.origin.x << "," <<
contentBounds.origin.y << ") " << contentBounds.size.width << " x " <<
contentBounds.size.height << std::endl;
ssDbg << "contentSize: " << contentSize.width << " x " <<
contentSize.height << std::endl;
my_log_debug(ssDbg.str().c_str());
The output forever even when the webView content has resized and become
scrollable:
[DEBUG 2010-09-08T23:57:02PDT]
docFrame: (0,0) 297 x 378
docBounds: (0,0) 297 x 378
webFrame: (0,0) 297 x 378
webBounds: (0,0) 297 x 378
contentFrame: (1,1) 298 x 379
contentBounds: (0,0) 298 x 379
contentSize: 298 x 379
I do find that the webView has one subView in its subviews array, and its
dimensions also never change, its bounds always are the same as its frame.
Anyone know what gives? Shouldn't the countentBounds and/or webBounds get
larger (taller) as new scrollbar-updating content is appended in the
webView? Then the following sample code to scroll to the bottom should
work:
if ([[scrollview documentView] isFlipped]) {
newScrollOrigin=NSMakePoint(0.0,NSMaxY([[scrollview documentView]
frame])
-NSHeight([[scrollview contentView]
bounds]));
} else {
newScrollOrigin=NSMakePoint(0.0,0.0);
}
...but it doesn't work because the contentView bounds never change even
though I can plainly see the webView now has a larger vertical dimension and
is vertically scrollable.
TIA,
Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden