• 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
(New) Loading a custom view and its subviews from a nib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(New) Loading a custom view and its subviews from a nib


  • Subject: (New) Loading a custom view and its subviews from a nib
  • From: "Cristian Savu" <email@hidden>
  • Date: Thu, 6 Jun 2002 15:25:24 +0300

In January, this year, there was a thread called like <subj> which was
saying this:

I have a custom view instantiated in my nib file. The view
contains other subviews such as buttons, etc. I want to be able to load
this custom view programatically and then install it as a subview of
some other view.

There were some solutions (see Ondra's replay *), but what if I need to
create more than one view (let's say <n>). I must connect
the outlets programmatically because I don't know the number of the views.
How can I do that ?


Regards, Cristian
*Ondra Cada replayed :
>>Just put the view into NIB, connect some outlet "newView" directly to it:

>>NSView *newView; // connected to the new view
>>NSView *oldView; // some original view, to be replaced by the new one

...
>>[[oldView superview] replaceSubview:oldView with:newView];
...

>>works like a charm. Of course, if you don't want to replace but just add,
>>addSubview: is there, too -- but in my experience, replacing is much more
>>frequent, and somewhat more complicated, so I described it ;)
_______________________________________________
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.

  • Prev by Date: Re: drawing NOW in a callback, boom!
  • Next by Date: http NSURLHandle subclass
  • Previous by thread: Re: [ANN] AccessorGenerator
  • Next by thread: http NSURLHandle subclass
  • Index(es):
    • Date
    • Thread