I have a segment control added to the navigation bar. It works fine. When i click on a segment (say index 0) it should load UIView A for me. and when i click on segment 1 it should load UIView B for me.
I have initialized UIVIew A in my .h file. and i am accessing it in the .m file as follows;
Here i am adding a Button and a label to View A
UIButton *buttonAdded= [UIButton buttonWithType:UIButtonTypeRoundedRect];
signUpButton.frame = CGRectMake(100, 100, 300, 50);
......
[self.viewA addSubview:buttonAdded];
// similarly added a label too
[self.viewA addSubview:labelAdded];
Now i added another Button and a Label to View B as the previous code;
// i have not shown how to declare a button and label, coz its same as above
[self.viewB addSubview:buttonAddedB];
[self.viewB addSubview:labelAddedB];
EDIT: I ADDED BOTH THESE VIEWS (View A & View B) IN THE VIEWDIDLOAD METHOD.
The problem is that when i click the segments nothing appears on the screen. Can someone please help me modify the code so it will work ?
Your viewA and viewB are NULL.
You have not allocated/initialized your viewA. There needs to be code somewhere that either hooks up a view from your nib (an IBOutlet), or you need something like this:
Then you can use viewA.