Re: NSView not resizing
Re: NSView not resizing
- Subject: Re: NSView not resizing
- From: Geoff Levner <email@hidden>
- Date: Sat, 14 May 2005 00:47:18 +0200
I believe you need to specify that the view needs to be redisplayed, i.e.:
[self setNeedsDisplay:YES];
Geoff
On 14 May 2005, at 00:26, Boisy G. Pitre wrote:
Greetings,
I am writing an NSView subclass which will automatically arrange other NSViews that are added to it via the addSubview method. To wit, I've written the following code:
- (void) didAddSubview:(NSView *)view
{
unsigned driveCount;
NSRect viewFrame;
float verticalPadding = 0.0f;
NSRect myFrame;
float boundsHeight;
driveCount = [[self subviews] count] - 1;
viewFrame = [view frame];
viewFrame.origin.y = (viewFrame.size.height + verticalPadding) * driveCount;
[view setFrame: viewFrame];
boundsHeight = (viewFrame.size.height + verticalPadding) * (driveCount + 1);
myFrame = [self frame];
myFrame.size.width = viewFrame.size.width;
myFrame.size.height = boundsHeight;
// Resize our JukeBox view
[self setBounds:NSMakeRect(0, 0, myFrame.size.width, myFrame.size.height)];
[self setFrame:myFrame];
}
(This method is called by the addSubview method, as stated in the NSView class documentation.)
In my document class, I add several views to this NSView-subclassed view, and I have added this very class (through IB) to my document's window with a very small size (2 pixels by 4 pixels). I would think that the setBounds and setFrame methods would properly resize the NSView in my document window, but alas, the resulting view is showing up as a 2x4 pixel area on my window.
I would have thought that setBounds and setFrame are sufficient to get a view to resize, so Is there something else I should be doing? Is "didAddSubview" the wrong place to perform this type of operation?
Boisy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden