• 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: NSSplitView autoresize only 1 of the 2 custom views
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSplitView autoresize only 1 of the 2 custom views


  • Subject: Re: NSSplitView autoresize only 1 of the 2 custom views
  • From: Peter Borg <email@hidden>
  • Date: Wed, 9 Jan 2008 19:55:17 +0100

On 9 jan 2008, at 19.13, Steven Crosley wrote:

Is there a way to get NSSplitView to only resize 1 of the views when expanding a window?

This would work similarly to Finder or iTunes where the left view would stay fixed in width but the right view would expand when resizing a window. I've played around with the autoresizes subviews checkbox, but haven't been able to work it successfully.


Hi!

I think you have to do this with code. Put something like this in your NSSplitView delegate:

- (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize: (NSSize)oldSize
{
CGFloat dividerThickness = [sender dividerThickness];
NSRect leftRect = [[[sender subviews] objectAtIndex:0] frame];
NSRect rightRect = [[[sender subviews] objectAtIndex:1] frame];
NSRect newFrame = [sender frame];

leftRect.size.height = newFrame.size.height;
leftRect.origin = NSMakePoint(0, 0);
rightRect.size.width = newFrame.size.width - leftRect.size.width - dividerThickness;
rightRect.size.height = newFrame.size.height;
rightRect.origin.x = leftRect.size.width + dividerThickness;

[[[sender subviews] objectAtIndex:0] setFrame:leftRect];
[[[sender subviews] objectAtIndex:1] setFrame:rightRect];
}


Cheers,

Peter
_______________________________________________

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


References: 
 >NSSplitView autoresize only 1 of the 2 custom views (From: Steven Crosley <email@hidden>)

  • Prev by Date: Re: NSImage to PDFPage in Tiger?
  • Next by Date: Re: Global Text replacemant
  • Previous by thread: NSSplitView autoresize only 1 of the 2 custom views
  • Next by thread: [MEET] Los Angeles Cocoaheads Thursday 1/10 at 7:30pm
  • Index(es):
    • Date
    • Thread