Skip navigation.
 
mlRe: NSView not resizing when parent view resizes
FROM : Ricky Sharp
DATE : Tue Dec 07 18:30:20 2004

On Tuesday, December 07, 2004, at 10:55AM, Michael Becker <space.<email_removed>> wrote:

>Am 07.12.2004 um 03:06 schrieb Michael Becker:

>> Here's something that bothers me: In my application, I have a custom
>> NSBox which holds an NSView. This NSView is again filled with a couple
>> of controls (TableView, Buttons, etc.). The NSView is defined in
>> Interface Builder and programmatically hooked to the NSBox subclass
>> (actually i have several of these NSViews, changing them
>> programmatically).

>
>I tried making the NSViews custom classes, where in their -drawRect:
>method I first set their size to be that of their respective superview.
>This works theoretically, but in practice I have very sloppy drawing.
>In fact, sometimes when I resize the window to be bigger, parts of the
>views won't be drawn. On the next invocation of their drawRect (e.g.
>when I click on them) they draw correctly.


You should never alter the size of things inside drawRect.  The only thing that should occur is drawing.

>What is happening? How can I make them resize smoothly according to
>their superviews?


I know you mentioned that you've called setAutoresizesSubviews:.  Have you also called setAutoresizingMask: to set up the appropriate options?  Ultimately, all your subviews should be receiving resizeWithOldSuperviewSize: messages.  NSView's default implementation of resizeWithOldSuperviewSize: is to use the options set up with setAutoresizingMask:.  You can also override resizeWithOldSuperviewSize if you need something custom.

--
Rick Sharp
Instant Interactive(tm)

Related mailsAuthorDate
mlNSView not resizing when parent view resizes Michael Becker Dec 7, 03:06
mlRe: NSView not resizing when parent view resizes Michael Becker Dec 7, 17:58
mlRe: NSView not resizing when parent view resizes Ricky Sharp Dec 7, 18:30
mlRe: NSView not resizing when parent view resizes Michael Becker Dec 8, 11:24
mlRe: NSView not resizing when parent view resizes John C. Randolph Dec 8, 19:02
mlRe: NSView not resizing when parent view resizes Michael Becker Dec 9, 11:52
mlRe: NSView not resizing when parent view resizes Louis C. Sacha Dec 9, 14:26
ml[SOLVED] Re: NSView not resizing when parent view resizes Michael Becker Dec 9, 15:14