0

I use .xib files for design

but most of my screens have the same structure, like 3 buttons and 2 label on top, remaining part is diff.

so I want to reuse buttons, labels from one .xib to another,

I have taken one parent-class for all similar screen so I created a label programatically in the parent-class which I can see in all its child class, but I want to do it using .xib

How can I use buttons in parent-class .xib to other child views?

I am doing that because I have the same header in 5 screens. header contains some buttons and labels, so I don't want to create the same design in each .xib

Benjamin Jimenez
  • 984
  • 12
  • 26
New iOS Dev
  • 1,937
  • 7
  • 33
  • 67
  • 1
    its not the way .xib works, make a controller with .xib which you can use into different controller as clid controller. – Retro Apr 02 '15 at 12:27
  • Thanks, yes I have controller with .xib, i have difficulty to reuse design in .xib to another screen – New iOS Dev Apr 02 '15 at 12:28
  • Just google to grasp the concept, start from here http://stackoverflow.com/questions/19826725/in-ios-using-storyboard-how-to-setup-a-view-controller-inside-a-container-view and http://sandmoose.com/post/35714028270/storyboards-with-custom-container-view-controllers – Retro Apr 02 '15 at 12:31

2 Answers2

0

NIB files (xib or storyboards) are not like cocoa-touch files. A nib file cannot be inherited or subclassed. Your option is to duplicate the original file and add your modifications manually.

Benjamin Jimenez
  • 984
  • 12
  • 26
0

You can also use the same .xib for ALL of the screens, but create properties/IBOutlets for the items you would like to change on each screen. Then simply change those items in the .m file at run time, rather than in the .xib itself.

Fluffhead
  • 845
  • 1
  • 9
  • 21