• 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
Re: constraining autoresizing of a splitview subview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: constraining autoresizing of a splitview subview


  • Subject: Re: constraining autoresizing of a splitview subview
  • From: Patrick Mau <email@hidden>
  • Date: Sun, 14 Dec 2008 01:51:45 +0100

Hi Christophe

The code below should be implemented in your NSSplitView's delegate.
The 'sender' argument is your splitView.

It will pick the first two subviews and adjust the width of
the right subview (index 1). The height will be adjusted to your
splitview's frame.

I hope it's useful,
Patrick

- (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize: (NSSize)oldSize
{
float dividerThickness = [sender dividerThickness];


    NSView *left = [[sender subviews] objectAtIndex:0];
    NSView *right = [[sender subviews] objectAtIndex:1];

    NSRect newFrame = [sender frame]; // the splitvies's new frame
    NSRect leftFrame = [left frame];
    NSRect rightFrame = [right frame];

    leftFrame.size.height = newFrame.size.height;

rightFrame.size.width = newFrame.size.width - leftFrame.size.width - dividerThickness;
rightFrame.size.height = newFrame.size.height;
rightFrame.origin.x = leftFrame.size.width + dividerThickness;


    [left setFrame:leftFrame];
    [right setFrame:rightFrame];
}

On 14.12.2008, at 01:39, christophe mckeon gonzalez de leon wrote:

hi,

i have a splitview containing two vertical subviews.
i'd like the user to be able to resize the the views at will
via. the divider, but when the splitview is resized due to
a window resize for instance, i want only one of the subviews
to be autoresized in the horizontal direction, while both
are resized appropriately in the vertical direction.

what would be the best/standard way of going about this?

thanks for any tips,
_c
_______________________________________________

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


  • Follow-Ups:
    • Re: constraining autoresizing of a splitview subview
      • From: "christophe mckeon gonzalez de leon" <email@hidden>
References: 
 >constraining autoresizing of a splitview subview (From: "christophe mckeon gonzalez de leon" <email@hidden>)

  • Prev by Date: Re: constraining autoresizing of a splitview subview
  • Next by Date: Re: Drawing NSTextFieldCell subclass in table view
  • Previous by thread: Re: constraining autoresizing of a splitview subview
  • Next by thread: Re: constraining autoresizing of a splitview subview
  • Index(es):
    • Date
    • Thread