tags:

views:

109

answers:

1

Hi All,

I am developing an iPhone application using iPhone SDK 3.0 . Its a view based application consisting tabbarcontroller. I need to change the viewcontrollers array of the tabbarcontroller dynamically.

I just done it using the following code:

[tabBarController setViewControllers:m_objArrtabbarViewControllers];

But it only changes the customizable viewcontrollers array, so I couldnt able to switch to a new view.

I need to know is it possible to change the viewcontrollers array of a tabbar.If yes how can I do that?

Regards, Syam S IPhone Devr.

A: 

I think you should implement following code to your application. I have given code of creating the tab bar dynamically.

tabBarObj=[[UITabBarController alloc]init]; //your tabBarobj in .h file
objFirstViewCtr=[[MyFirstViewController alloc] init]; // your view controller object in .h File 
must be #import "MyFirstViewController.h"
objSecondViewCtr=[[MySecondViewController alloc] init]; // same way your second viewobj
UINavigationController *v1=[[[UINavigationController alloc] initWithRootViewController: objFirstViewCtr] autorelease];
UINavigationController *v2=[[[UINavigationController alloc] initWithRootViewController: objSecondViewCtr] autorelease];

tabBarObj.viewControllers=[NSArray arrayWithObjects:v1,v2,nil];

[self.view addSubView:tabBarObj.View];
sugar