1
votes

I'm making a Cocoa application which has an NSSavePanel. During the lifetime of the modality of this panel, I allow the user to toggle between two different accessory views (call them View A and View B) for this panel via a checkbox in both of these views. I'm building on Snow Leopard.

View B is larger heightwise than View A. When switching from View B to View A, Cocoa starts with the height of the save panel plus View B's height, draws View A at the bottom of the panel with a blank space at the top of View A and then slowly animates this space away so that View A slides upwards. This looks okay.

When switching from View A to View B, Cocoa draws View B's components at the very top of the save panel so that they overlap the save panel's own components (text fields, buttons, etc.). It then slides View B downwards to underneath the save panel's own components. This looks ugly.

First off, I'm not sure how to reason about the proper way to animate the transition from View A to View B. Secondly, I'm not sure to accomplish it. I suppose I could just have one accessory view and just show and hide components in this when switching from basic to advanced mode, but this seems kind of a kludge.

Any suggestions? Thanks in advance.

1

1 Answers

1
votes

The easiest way I've found to do things like this is to use an NSTabView with no visible tabs that does NOT draw the background. A and B are subviews of the tab view. Use the checkbox to toggle between the subviews of the NSTabView -- create an action method that uses -[NSTabView selectTabViewItemAtIndex:]. Then you don't have to worry about the height changing and Cocoa handles the transition.