• 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: How to toggle the subviews of a split view?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to toggle the subviews of a split view?


  • Subject: Re: How to toggle the subviews of a split view?
  • From: Greg Titus <email@hidden>
  • Date: Fri, 13 Dec 2002 18:51:44 -0800

Having a view access the scrollview that it is contained within is such a common operation that Apple has already added the requisite method to NSView: the -enclosingScrollView method.

Hope this helps,
-Greg

On Friday, December 13, 2002, at 06:31 PM, John C. Randolph wrote:

On a slightly related topic, some time ago, I wrote this:

- (NSView *) ancestorViewOfClass:(Class) aClass
{
NSView
*result = self;
while (result = [result superview])
if ([result isKindOfClass:aClass)
return result;
return nil;
}

..in a category of NSView to simplify walking up a view hierarchy to find (say) the scrollview or splitview or whatnot that contained the receiver. This way, I don't need to keep track of how many steps back up the chain it is to the view I want.

-jcr

On Friday, December 13, 2002, at 05:31 PM, Jacob Engstrand wrote:

John Clayton wrote:

I use the
outermost custom view in the subview to do the resizing, I get it's
frame, create a new rect with the width I want, and then set the frame
to the new rect. Seems like it should work, but logging tells me that
the final resized frame has a different width than the one I have set.
Hmmm.


This used to drive me mad, too. Until I realized that you need to set the sizes of the actual subviews of the split view. Sort of like this (myTableView is one of the two things I put in the split view):


[[[myTableView superview] superview] setFrame: myFrame];

Since the first superview of a table view is a clip view and the next is the scroller, and it is the scroller that is the direct subview of the NSSplitView and is the one you need to set.

For a textedit, it is even worse:

[[[[myTextEdit superview] superview] superview] setFrame: myTextEditFrame];


Of course, remeber to set the frame sizes _exactly_ right, so the hights of the frames and the divider together fill the entire height of the BSSplitView. (But I guess you already knew that, huh?)

Also, be sure to let the window resize itself _before_ calculating the frame sizes and calling -adjustSubviews (like if you open the Window and resize it programatically before showing, you dont want to call -adjustSubviews in the windowDidLoad or awakeFromNib.)

Hope this helps. (Someone please tell me if I'm wrong! I'd actually like to be wrong in this case! :)

/jak

_________________________________________________________
Magician. Have rabbit. Will travel.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: How to toggle the subviews of a split view? (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: Subject: Re: Cocoa Book
  • Next by Date: Re: Help me please to find a job in Cocoa
  • Previous by thread: Re: How to toggle the subviews of a split view?
  • Next by thread: Re: How to toggle the subviews of a split view?
  • Index(es):
    • Date
    • Thread