• 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: Hiding a view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hiding a view


  • Subject: Re: Hiding a view
  • From: Mason Mark <email@hidden>
  • Date: Thu, 25 Oct 2001 15:48:29 -0700

--On Thursday, October 25, 2001 11:36 AM -0700 Dustin Mierau <email@hidden> wrote:

Morning people.

Damn, I thought this was a simple question...

Yeah, this comes up periodically.

Originally (when I was starting with Cocoa), I thought this was a stupid omission not to have a show/hide API. I still think the stated reasons for it (principle of least surprise / always show the user everything and nothing should disappear) are not valid ones in the context of justifying why such an API is not provided.

They might describe a good ideal scenario, but modern software certainly has thousands of legitimate reasons to make things appear and go away on screen.

However, I now *love* Cocoa's way of doing this, mainly because, as somebody else mentioned in this thread, when you make a view disappear, you are conceptually "removing" it from the window. By actually removing the view from the window, you are also removing it from the event processing chain, so the window never has to think about its "hidden" views.

If the view to be hidden might change its size or position, using -replaceSubview:with: to replace the view with a simple NSView that clones the disappearing view's size and sizing attributes is a very convenient way to do it.

--
Mason

P.S.
As Erik Buck pointed out, in your particular case you should just set the text of the view, though...


References: 
 >Re: Hiding a view (From: Dustin Mierau <email@hidden>)

  • Prev by Date: Re: Out-of-date Dev Docs?
  • Next by Date: Re: conventions
  • Previous by thread: Re: Hiding a view
  • Next by thread: Re: Hiding a view
  • Index(es):
    • Date
    • Thread