• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSView not resizing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSView not resizing


  • Subject: NSView not resizing
  • From: "Boisy G. Pitre" <email@hidden>
  • Date: Fri, 13 May 2005 17:26:49 -0500

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

  • Follow-Ups:
    • Re: NSView not resizing
      • From: j o a r <email@hidden>
    • Re: NSView not resizing
      • From: Geoff Levner <email@hidden>
  • Prev by Date: Re: Display Keys-Values in Spotligh
  • Next by Date: Re: Runtime error: _NSAutoreleaseNoPool
  • Previous by thread: Newbie: NSConnection sendInvocation problem?
  • Next by thread: Re: NSView not resizing
  • Index(es):
    • Date
    • Thread