Yet another way of Hiding a view
Yet another way of Hiding a view
- Subject: Yet another way of Hiding a view
- From: "Erik M. Buck" <email@hidden>
- Date: Thu, 25 Oct 2001 10:11:33 -0500
replaceSubview:with:
- (void)replaceSubview:(NSView *)oldView with:(NSView *)newView
Replaces oldView with newView in the receiver's subviews. Does nothing and
returns nil if oldView is not a subview of the receiver.
This method causes oldView to be released; if you plan to reuse it, be sure
to retain it before sending this message and to release it as appropriate
when adding it as a subview of another NSView.
See Also: - addSubview: - addSubview:positioned:relativeTo:
When you want to hide a view, replace it with an empty view (a NSBox or just
an NSView) that is the same size and has the same resizing options.
When you want to restore a view, replace the empty view with your view
making sure the size is the same as the view being replaced.
This will make sure that resizing works even when the view is hidden.