0

I like to create a small custom view class named Configurator that derives from UIView. I would like the IBOutlets and IBActions to be placed in the Configurator itself (and not in any view controller). I have created the layout in IB where I also indicated that the Files Owner belong to class Configurator.

My problem is that when I load the view, using the code snippet below, I have to supply the owner. But the owner is the object beeing loaded.`

NSArray *arr = [[NSBundle mainBundle] loadNibNamed:@"configurator" owner:???? options:nil]; Configurator *viewConf = [arr objectAtIndex:0];

Question: How to load a view when its outlets and actions are contained in the view being loaded?

EDIT: My main-view will load the small Configurator-view and display it in a small part of the screen. I cannot set owner to self because that would imply that the outlets and actions where located in the main view.

ragnarius
  • 5,642
  • 10
  • 47
  • 68

2 Answers2

0

Usually a controller loads a view. A view loading itself does not seem right. When you have a separate controller loading the view, the owner will be the controller.

Adithya
  • 4,545
  • 3
  • 25
  • 28
0

Keep the owner as self. This will work same as we use Custom UITableViewCell as shown below:

NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil];
cell = (MyCell *)[nib objectAtIndex:0];

This will refer to your custom view IBOutlets and IBActions only.

Hope this will clear your doubts.

Mrunal
  • 13,982
  • 6
  • 52
  • 96