How to load multiple xibs in a single xib?

I've created 4 xibs of width 200,height 200 for a purpose...but if i want to load all xib in a single xib i dont know to achieve that..I got a couple of ideas

1.Can we make all the xib to load by group of arrays?

2.Can we declare NSBUNDLE code at appdelegate.m file?..

Answers


each xib must have a class for control it. So you now must have 4 xib , 4 .h and 4 .m files. Now create another view controller with xib, .m and .h (MainViewController). Now import all the class. in MainController.h

#import <UIKit/UIKit.h>
#import "Xib1Class.h"
#import "Xib2Class.h"
#import "Xib3Class.h"
#import "Xib4Class.h"

@interface MainViewController : UIViewController {

    Xib1Class *xib1Class;
    Xib2Class *xib2Class;
    Xib3Class *xib3Class;
    Xib4Class *xib4Class;

}

@end

in viewDidLoad of MainViewController.m

xib1Class = [[Xib1Class alloc] initWithNibName:@"Xib1Class" bundle:nil];
xib2Class = [[Xib2Class alloc] initWithNibName:@"Xib2Class" bundle:nil];
xib3Class = [[Xib3Class alloc] initWithNibName:@"Xib3Class" bundle:nil];
xib4Class = [[Xib4Class alloc] initWithNibName:@"Xib4Class" bundle:nil];

//set the frame
xib1Class.view.frame = CGRectMake(x,y,w,h);
..........
//put in main view
[self.view addSubView:xib1class.view];
//the same for 2-3-4

remember to manage memory. Hope this help u.


Need Your Help

Python global keyword behavior

python global

I am trying to use a global variable across modules by importing the variable and modifying it locally within a function. The code and the output is below. The last output is not what I expected, I

Remove Non English Characters PHP

php character

how can i parse a string to remove all non english characters in php