i am developing an iOS application. I have a controller : iPhonePopUpController, in this controller i have a xib like this image :
My question is, can i add an other xib to this Controller and loaded it when i need it or should i create a second controller to load my second xib ? 
You can load anything from a XIB using:
This line unarchive the XIB named
YourOtherXIB.xibby creating the instances of the objects you have in your XIB, and then connect all the outlets and actions you defined in the XIB, and return the list of top-level objects.When you create a XIB whose File’s Owner is an
UIViewController, typically you then initialize yourUIViewControllerusing code like this:What this code basically do internally is that it stores the
nibNameandbundleyou provide in some internal property, and when it needs to load its view (especially the first time it needs to display it onscreen), it loads the view from the XIB using something like the line quoted above:As you connected the view in your XIB to the
viewIBOutlet of theFile's Owner‘s (which in that case is theselfpassed as an argument, namely theUIViewControlleritself), then theviewproperty of yourUIViewControllerwill be populated with the view that has just been unarchived from the XIB. And that’s howUIViewControllerloads its view from a XIB file.But of course you can do the same for your own classes and do not need your File’s Owner to be an
UIViewController. Simply make your File’s Owner be whatever class fits your need, expose a custom IBOutlet from this class and connect it to your objects in your XIB.MyCustomClassclass that declares anIBOutlet UIView* myOtherView;. Define the class of yourFile's Ownerin your XIB to be of the classMyCustomClass, then bind themyOtherViewoutlet to the view to load from your XIB. Then in the code, create an instance ofMyCustomClassand use the aboveloadNibNamed:owner:options:method by passing thisMyCustomClassinstance as theownerparameterUIViewControllerthat loaded your primary XIB to load your other view from your secondary XIB too: simply add anIBOutlet UIView* otherViewin yourUIViewControllersubclass. In your first XIB, you will connect theviewIBOutlet to your primary view but keep theotherViewIBOutlet unconnected. In your second XIB, you will connect theotherViewIBOutlet to your other view but keepviewIBOutlet unconnected. When loading yourUIViewControllerwith the first XIB, theviewproperty will be set to the view loaded from your XIB. Then if you want to lazy-load theotherViewfrom the other XIB at a later time, simply callloadNibNamed:owner:optionswithOtherXIB.xibas the nib name andselfas the owner. TheOtherXIBwill be unarchived andotherViewproperty will be filled with that loaded view.