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

Re: Loading a custom view and its subviews from a nib


  • Subject: Re: Loading a custom view and its subviews from a nib
  • From: Stéphane Sudre <email@hidden>
  • Date: Fri, 11 Jan 2002 17:38:48 +0100

On Friday, January 11, 2002, at 04:39 PM, Robert Miller wrote:

Hello,

This is probably a basic question but I've had no l uck solving the
problem. 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. I've been using NSBundle to do this and it appears to
create the view but not any of the subviews that are inside of the
custom view that is instantiated in the nib.. I've included one of the
coding attempts below? Any information on how to do this is greatly
appreciated.

NSBundle *bundle = [NSBundle mainBundle];
Class bundleClass = [bundle classNamed:@"MyClassName"];
id component = [[bundleClass alloc]
initWithFrame:NSMakeRect(0,0,256,64)];

Since you're creating an instance, it can't be the one in your Nib.

What you can do is to create an outlet in your main controller to your custom view.

Then you do:

[mySuperView addSubview:myCustomView];


References: 
 >Loading a custom view and its subviews from a nib (From: Robert Miller <email@hidden>)

  • Prev by Date: Re: Resize transparent windows
  • Next by Date: Re: always-on computing (Easiest way to delete a file)
  • Previous by thread: Loading a custom view and its subviews from a nib
  • Next by thread: Re: Loading a custom view and its subviews from a nib
  • Index(es):
    • Date
    • Thread