views:

344

answers:

1

Greetings all,

I have a puzzling problem. I have a pointer to a vanilla NSView that was initialized in a nib. I message the nsview with

[myNSView setFrame:NSMakeRect(0,0,816,1056)];

but when I step through the debugger, myNSView has a frame of {{0,0}, {801, 1041}}. The dimensions of the rectangle are 15 less than I've specified! This happens consistently. If I specify two [setFrames] in a row, everything works, but that's of course not the answer.

To summarize, does anyone know why setFrame would fail?

Thanks

+4  A: 

15px is exactly the size of an NSScroller at NSRegularControlSize.

My guess is that you have your NSScrollView configured to automatically hide scrollers.

Try turning off the horizontal and vertical scrollers of your scrollView in the NIB, if that solves the problem, you'll know where to look from there.  It is something related to the clipView of the scrollView autoresizing the documentView. The clipView itself is being autoresized when the scrollers appear; directly after you set the documentView to a frameSize (the 100% setting I'd guess) that requires scrollers.

Dirk Stoop
That was brilliant, thank you so much!I turned of the scrollers and everything fits now.So, the reasoning is something like this:1. I change the pageview size2. scroll view updates to include scrollers3. clipview resizes to accomodate scrollers and resizes subviews which includes pageview.Right?
EightyEight
Yep, exactly :) If you surround your setFrame: call with [[theScrollView contentView] setAutoresizesSubviews: NO]; and toggle it back on when done, I think that should do the trick.
Dirk Stoop