I seem to have a problem with my tabBar items. Doing the creation of the tabBar I'm able to set this property of the tabBarItem that I want like so:
viewController2 = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
UIViewController *viewController3 = [[ThirdViewController alloc]initWithNibName:#"ThirdViewController" bundle:nil];
UIViewController *viewController4 = [[FourthViewController alloc]initWithNibName:#"FourthViewController" bundle:nil];
//Create our NavigationViewController object
NavigationViewController *navController = [[NavigationViewController alloc] initWithNibName:#"NavigationViewController" bundle:nil];
//Create our UINavigationController
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:navController];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = #[nav, viewController2, viewController4, viewController3];
nav.tabBarItem = [[UITabBarItem alloc]
initWithTitle:(#"Menukort")
image:[UIImage imageNamed:#"162-receipt.png"]
tag:0];
viewController2.tabBarItem = [[UITabBarItem alloc]
initWithTitle:(#"Favoritter")
image:[UIImage imageNamed:#"28-star.png"]
tag:1];
viewController3.tabBarItem = [[UITabBarItem alloc]
initWithTitle:(#"Info")
image:[UIImage imageNamed:#"104-index-cards.png"]
tag:2];
viewController4.tabBarItem = [[UITabBarItem alloc]
initWithTitle:(#"Kort")
image:[UIImage imageNamed:#"103-map.png"]
tag:3];
viewController2.tabBarItem.badgeValue = #"1";
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
All this code is within a singleton, so sharing objects shouldn't be a problem. Now - how would I set the badgeValue of this tabBarItem in another class?
Thanks in advance.
Get array of tabbarController's viewController using
NSArray *arr = [self.tabbarController viewController];
Then set value for any view controller using
[[[arr objectIndex:1] tabBarItem] setbadgeValue:<nsinteger some value>];
Found the answer myself in another thread.
I did it like this:
[[[[[self tabBarController] tabBar] items]
objectAtIndex:tabIndex] setBadgeValue:badgeValueString];
Related
My app has a first page containing a UITabBarController and tabBar.
But when I pushViewController to UINavigationController , my UITabBarController is not showing.
appdelegate:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
anasayfaViewController * firstTab= [[anasayfaViewController alloc] initWithNibName:#"anasayfaViewController" bundle:nil];
SehirRehberiViewController *sehirRehberi = [[SehirRehberiViewController alloc] initWithNibName:#"SehirRehberiViewController" bundle:nil];
duyuruViewController *duyuru = [[duyuruViewController alloc] initWithNibName:#"duyuruViewController" bundle:nil];
sikayetViewController *sikayet = [[sikayetViewController alloc] initWithNibName:#"sikayetViewController" bundle:nil];
digerViewController *diger = [[digerViewController alloc] initWithNibName:#"digerViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = #[firstTab,sehirRehberi,duyuru,sikayet,diger];
navigationController=[[UINavigationController alloc]initWithRootViewController:self.tabBarController];
self.window.rootViewController = self.navigationController;
// [self.window addSubview:self.navigationController.view];
[self.window makeKeyAndVisible];
return YES;
firstTab viewcontroller have button and click events:
-(void)btnClick:(id)sender
{
[self.navigationController pushViewController:haberler animated:NO];
}
when I click UIViewController it is opening, but not showing UITabBarController. How can I solve this problem?
You have UITabBarController as rootViewController of your UINavigationController. And UINavigationController as root Controller of your app. Instead of that you have to set UITabBarController as root Controller of your App and add UINavigationController in each tab.
Check this answer.
You should try using my following snippet
anasayfaViewController * firstTab= [[anasayfaViewController alloc] initWithNibName:#"anasayfaViewController" bundle:nil];
UINavigationController *firstNav = [[UINavigationController alloc] initWithRootViewController:firstTab];
SehirRehberiViewController *sehirRehberi = [[SehirRehberiViewController alloc] initWithNibName:#"SehirRehberiViewController" bundle:nil];
UINavigationController *secondNav = [[UINavigationController alloc] initWithRootViewController:sehirRehberi];
// object for tabbarviewcontroller
self.tab.viewControllers = [NSArray arrayWithObjects:firstNav,secondNav,nil];
I've shown you the sample for two tabs inside tabbarcontroller. You can customise it as per your need.
Enjoy Programming!
First thing is that you need to create Array of Your All view-controller(Navigation Controller) like
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navigationController2,navigationController1,navigationController3,nil];
and
you need to set Winodw's Rootviewcontroller is
[self.window setRootViewController:tabBarController]; not a Navigationcontroller
As par you Code example:-
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
anasayfaViewController * firstTab= [[anasayfaViewController alloc] initWithNibName:#"anasayfaViewController" bundle:nil];
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:firstTab];
SehirRehberiViewController *sehirRehberi = [[SehirRehberiViewController alloc] initWithNibName:#"SehirRehberiViewController" bundle:nil];
UINavigationController *navigationController2 = [[UINavigationController alloc] initWithRootViewController:sehirRehberi];
duyuruViewController *duyuru = [[duyuruViewController alloc] initWithNibName:#"duyuruViewController" bundle:nil];
UINavigationController *navigationController3 = [[UINavigationController alloc] initWithRootViewController:duyuru];
sikayetViewController *sikayet = [[sikayetViewController alloc] initWithNibName:#"sikayetViewController" bundle:nil];
UINavigationController *navigationController4 = [[UINavigationController alloc] initWithRootViewController:sikayet];
digerViewController *diger = [[digerViewController alloc] initWithNibName:#"digerViewController" bundle:nil];
UINavigationController *navigationController5 = [[UINavigationController alloc] initWithRootViewController:diger];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = #[navigationController1,navigationController2,navigationController3,navigationController4,navigationController5];
[self.window setRootViewController:tabBarController];
[self.window makeKeyAndVisible];
return YES;
UPDATE:-
If you want to TabbarController adding at button Click for NextViewcontroller then you can do with something different way like Bellow :-
For example you have loginScreen while app lonch and it login button click you need to push a view-controller and that View-controller contain those Tabbar.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
LoginViewcontroller *objLogin = [[LoginViewcontroller alloc] initWithNibName:#"LoginViewcontroller" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
In loginViewcontroller LoginButton action:-
-(IBAction)LoginSuccess
{
anasayfaViewController * firstTab= [[anasayfaViewController alloc] initWithNibName:#"anasayfaViewController" bundle:nil];
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:firstTab];
SehirRehberiViewController *sehirRehberi = [[SehirRehberiViewController alloc] initWithNibName:#"SehirRehberiViewController" bundle:nil];
UINavigationController *navigationController2 = [[UINavigationController alloc] initWithRootViewController:sehirRehberi];
duyuruViewController *duyuru = [[duyuruViewController alloc] initWithNibName:#"duyuruViewController" bundle:nil];
UINavigationController *navigationController3 = [[UINavigationController alloc] initWithRootViewController:duyuru];
sikayetViewController *sikayet = [[sikayetViewController alloc] initWithNibName:#"sikayetViewController" bundle:nil];
UINavigationController *navigationController4 = [[UINavigationController alloc] initWithRootViewController:sikayet];
digerViewController *diger = [[digerViewController alloc] initWithNibName:#"digerViewController" bundle:nil];
UINavigationController *navigationController5 = [[UINavigationController alloc] initWithRootViewController:diger];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = #[navigationController1,navigationController2,navigationController3,navigationController4,navigationController5];
[self.navigationController pushViewController:self.tabBarController animated:YES];
}
I've been looking at programatically adding a tab bar to my view controller because having a scroll view I can't place it on without it being in the middle of my view. I'm abit confused about how to add it. Does it need to be initiated in my ViewDidLoad method or my AppDelegate?
If I have:
UITabBarController *tabBar = [[UITabBarController alloc] init];
[self.view addSubview:tabBar.view];
[tabBar release];
How can I allocate it to the bottom of my scrollview?
Thanks!
Now in my appDelegate class :
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
ViewController* vc = [[ViewController alloc] init];
NSArray* controllers = [NSArray arrayWithObjects:vc, tabBarController, nil];
tabBarController.viewControllers = controllers;
[_window addSubview:tabBarController.view];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
It's crashing and not sure if it's a release I'm missing.
Edit:
For anyone else wondering this in Appdelegate.m:
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = #[viewController1, viewController2, viewController3, viewController4];
Take a look at this Documentation given by Apple: ViewControllers.
Sample Code :
- (void)applicationDidFinishLaunching:(UIApplication *)application {
UITabBarController *tabBarController = [[UITabBarController alloc] init];
FirstViewController* vc1 = [[FirstViewController alloc] init];
SecondViewController* vc2 = [[SecondViewController alloc] init];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil];
tabBarController.viewControllers = controllers;
// Add the tab bar controller's current view as a subview of the window
[window addSubview:tabBarController.view];
}
I did it this way. I copied this from my App Delegate and it works fine. Basically you add the view controllers to the tab bar then add the tab bar to the window's subview.
Instantiate the instance
iVacationTabBar = [[UITabBarController alloc] init];
However you create the views/view controllers:
UINavigationController *rvc_tools = [[UINavigationController alloc] initWithRootViewController: vc_tools];
UINavigationController *rvc_settings = [[UINavigationController alloc] initWithRootViewController: vc_settings];
UINavigationController *rvc_about = [[UINavigationController alloc] initWithRootViewController: vc_about];
UINavigationController *rvc_currentpage = [[UINavigationController alloc] initWithRootViewController: vc_currentpage];
UINavigationController *rvc_backup = [[UINavigationController alloc] initWithRootViewController:vc_backup];
Add the controllers to the array:
NSArray* controllers = [NSArray arrayWithObjects: rvc_currentpage, rvc_tools,rvc_settings, rvc_backup, rvc_about, nil];
Set the array of view controllers to your tab bar:
[iVacationTabBar setViewControllers: controllers animated:NO];
Add the tab bar to the window's subview.
[_window addSubview:iVacationTabBar.view];
You can not add a UITabbarController on a UIViewController. Instead, on a ViewController you have to show the TabbarController, create a TabbarController, set ViewControllers for it, and add it to a Window.
i have added tab bar in app delegate. When i pushed the view from one of my view te tab bar got removed. I want that tab bar on pushed view also.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
AudioViewController * audioViewController = [[AudioViewController alloc] initWithNibName:#"AudioViewController" bundle:nil];
audioViewController.title = #"audio";
audioViewController.tabBarItem.image=[UIImage imageNamed:#"audio 30x30.png"];
ViewController *videoViewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
videoViewController.title = #"video";
videoViewController.tabBarItem.image=[UIImage imageNamed:#"video 30x30.png"];
ViewController *aboutViewController = [[ViewController alloc]initWithNibName:#"ViewController" bundle:nil];
aboutViewController.title = #"about";
aboutViewController.tabBarItem.image=[UIImage imageNamed:#"about1_iPhone.png"];
ViewController *infoViewController = [[ViewController alloc]initWithNibName:#"ViewController" bundle:nil];
infoViewController.title = #"info";
infoViewController.tabBarItem.image=[UIImage imageNamed:#"info 30x30.png"];
PlaylistViewController *PlaylistViewControllerObj = [[PlaylistViewController alloc]initWithNibName:#"PlaylistViewController" bundle:nil];
PlaylistViewControllerObj.title = #"Playlist";
PlaylistViewControllerObj.tabBarItem.image=[UIImage imageNamed:#"ko.png"];
NSArray *viewControllerArray = [NSArray arrayWithObjects:audioViewController,videoViewController,aboutViewController,infoViewController,PlaylistViewControllerObj,nil];
UITabBarController * myTabbarController = [[UITabBarController alloc] init];
[myTabbarController setViewControllers:viewControllerArray];
navigationControllerObj = [[UINavigationController alloc] initWithRootViewController:myTabbarController];
[navigationControllerObj setNavigationBarHidden:YES animated:NO];
self.window.rootViewController =navigationControllerObj;
}
UIViewController *viewController1, *viewController2, *viewController3 , *viewController4 , *viewController5 ;
viewController1 = [[Homeviewcontroller alloc] initWithNibName:nil bundle:nil];
viewController2 = [[NearbyViewController alloc] initWithNibName:nil bundle:nil];
viewController3 = [[SearchViewController alloc] initWithNibName:nil bundle:nil];
viewController4 = [[FavoritiesViewController alloc] initWithNibName:nil bundle:nil];
viewController5 = [[MoreViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *homeNavi=[[UINavigationController alloc]initWithRootViewController:viewController1];
UINavigationController *SearchNavi=[[UINavigationController alloc]initWithRootViewController:viewController3];
UINavigationController *NearbyNavi=[[UINavigationController alloc]initWithRootViewController:viewController2];
UINavigationController *FavNavi=[[UINavigationController alloc]initWithRootViewController:viewController4];
UINavigationController *MoreNavi=[[UINavigationController alloc]initWithRootViewController:viewController5];
TabbarController = [[UITabBarController alloc] init];
TabbarController.viewControllers = [NSArray arrayWithObjects:homeNavi,SearchNavi,NearbyNavi,FavNavi,MoreNavi, nil];
[self presentModalViewController:TabbarController animated:YES];
Check value of this property in the UIViewController you are pushing
#property(nonatomic) BOOL hidesBottomBarWhenPushed
Try this sample code
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
AudioViewController * audioViewController = [[AudioViewController alloc] initWithNibName:#"AudioViewController" bundle:nil];
audioViewController.title = #"audio";
audioViewController.tabBarItem.image=[UIImage imageNamed:#"audio 30x30.png"];
UINavigationController *navaudioViewController = [[UINavigationController alloc] initWithRootViewController:audioViewController];
PlaylistViewController *PlaylistViewControllerObj = [[PlaylistViewController alloc]initWithNibName:#"PlaylistViewController" bundle:nil];
PlaylistViewControllerObj.title = #"Playlist";
PlaylistViewControllerObj.tabBarItem.image=[UIImage imageNamed:#"ko.png"];
UINavigationController *navPlaylistView = [[UINavigationController alloc] initWithRootViewController:PlaylistViewControllerObj];
UITabBarController * myTabbarController = [[UITabBarController alloc] init];
myTabbarController.viewControllers = #[navHomeController,navPlaylistView];
self.window.rootViewController = myTabbarController;
[self.window makeKeyAndVisible];
return YES;
}
Use This Code
call this method , where to present UITabBar
In .h,
#property (strong, nonatomic) UINavigationController *navigation;
#property(nonatomic, strong) UITabBarController *tabbarcontroller;
In .m,
-(void)loadtabview
{
self.tabbarcontroller = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:4];
self.firstViewController = [[FirstViewController alloc]initWithNibName:#"firstViewController" bundle:nil];
navigation = [[UINavigationController alloc] initWithRootViewController:self.firstViewController];
self.viewController.navigationItem.title=#"First";
[localControllersArray addObject:navigation];
self.secondViewController = [[secondViewController alloc] initWithNibName:#"secondViewController" bundle:nil];
navigation = [[UINavigationController alloc] initWithRootViewController:secondViewController];
self.secondViewController.navigationItem.title=#"second";
[localControllersArray addObject:navigation];
self.ThirdViewController = [[Third ViewController alloc]initWithNibName:#"Third ViewController" bundle:nil];
navigation = [[UINavigationController alloc] initWithRootViewController:ThirdViewController];
self.secondViewController.navigationItem.title=#"Third";
[localControllersArray addObject:navigation];
tabbarcontroller.viewControllers = localControllersArray;
self.tabbarcontroller.delegate = self;
[self.tabbarcontroller setSelectedIndex:0];
[self.window addSubview:tabbarcontroller.view];
}
In a UITabBarController, upon selecting a tab, I want that tab's UIViewController to change (assign a new viewcontroller). I'm trying this-
NSMutableArray *tabBarViewControllers = [myUITabBarController.viewControllers mutableCopy];
[tabbarViewControllers replaceObjectAtIndex:0 withObject:[[myViewcontroller1 alloc] init]];
[myUITabBarController setViewControllers:tabbarViewControllers];
But it gives error. How to assign a new UIViewController and refresh instantly?
This is based on femina's answer but doesn't require you to build the whole array of view controllers, it just lets you replace an existing view controller with another. In my case I wanted to swap in a different xib file for the iPhone 5 screen:
if ([[UIScreen mainScreen] bounds].size.height == 568) {
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
Tracking *tracking568h = [[Tracking alloc] initWithNibName:#"Tracking-568h" bundle:nil];
tracking568h.title = [[viewControllers objectAtIndex:0] title];
tracking568h.tabBarItem = [[viewControllers objectAtIndex:0] tabBarItem];
[viewControllers replaceObjectAtIndex:0 withObject:tracking568h];
[tracking568h release];
[self.tabBarController setViewControllers:viewControllers animated:FALSE];
}
This changes the view controller for the first tab, keeping the same tab icon and label.
Please see this code , it offers 2 tabbar's with navigation.
In the AppDelegate.h please declare
UINavigationController *nav1;
UINavigationController *nav2;
UITabBarController *tab;
And in the Appdelegate.m , in the didFinishLaunchingWithOptions please add:-
tab = [[UITabBarController alloc]init];
ViewController *view1 = [[ViewController alloc]init];
nav1= [[UINavigationController alloc]initWithRootViewController:view1];
UITabBarItem *tab1 = [[UITabBarItem alloc]initWithTitle:#"Add" image:[UIImage imageNamed:#"Plus.png"] tag:1];
view1.title = #"Add";
[view1 setTabBarItem:tab1];
SettingsViewController *view2 = [[SettingsViewController alloc]init];
nav2= [[UINavigationController alloc]initWithRootViewController:view2];
UITabBarItem *tab2 = [[UITabBarItem alloc]initWithTitle:#"Setting" image:[UIImage imageNamed:#"settings.png"] tag:2];
view2.title = #"Setting";
[view2 setTabBarItem:tab2];
tab.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nil];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = tab;
Also check this link for further implementation ... Hope this helps :)
UItabBar changing View Controllers
In the AppDelegate.h
UIViewController *vc1;
UIViewController *vc2;
UIViewController *vc3;
in the Appdelegate.m
in the didFinishLaunchingWithOptions
NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init];
vc1 = [[UIViewController alloc] init];
vc1.title = #"A";
[listOfViewControllers addObject:vc1];
vc2 = [[UIViewController alloc] init];
vc2.title = #"B";
[listOfViewControllers addObject:vc2];
vc3 = [[UIViewController alloc] init];
vc3.title = #"C";
[listOfViewControllers addObject:vc3];
[self.tabBarController setViewControllers:listOfViewControllers
animated:YES];
According to Apple, I can combine UINavigationController and UITabBarController using the code, e.g.
MyViewController1* vc1 = [[MyViewController1 alloc] init];
MyViewController2* vc2 = [[MyViewController2 alloc] init];
MyViewController3* vc3 = [[MyViewController3 alloc] init];
MyNavRootViewController* vc4 = [[MyNavRootViewController alloc] init];
UINavigationController* navController = [[UINavigationController alloc]
initWithRootViewController:vc4];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, vc3, navController, nil];
tabBarController.viewControllers = controllers;
In this setup, only vc4 has the UINavigationController, but what if I want vc1-vc3 also has the UINavigationController?, should I do like..
MyViewController1* vc1 = [[MyViewController1 alloc] init];
UINavigationController* nv1 = [[UINavigationController alloc]
initWithRootViewController:vc1];
MyViewController1* vc2 = [[MyViewController2 alloc] init];
UINavigationController* nv2= [[UINavigationController alloc]
initWithRootViewController:vc2];
MyViewController1* vc3 = [[MyViewController3 alloc] init];
UINavigationController* nv3 = [[UINavigationController alloc]
initWithRootViewController:vc3];
NSArray* controllers = [NSArray arrayWithObjects:nv1, nv2, nv3, nil];
tabBarController.viewControllers = controllers;
Is this the right approach?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [self initializeTabBarItems];
self.navigationController = [[UINavigationController alloc]init];
[self.navigationController setNavigationBarHidden:YES];
self.window.rootViewController = self.navigationController;
[self.navigationController pushViewController:_tabBarController animated:YES];
[self.window makeKeyAndVisible];
return YES;
}
- (NSArray *)initializeTabBarItems
{
NSArray * retval;
/* Initialize view controllers */
UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:#"FirstViewController" bundle:nil] autorelease];
UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil] autorelease];
UIViewController *viewController3 = [[[ThirdViewController alloc]initWithNibName:#"ThirdViewController" bundle:nil]autorelease];
UIViewController *viewController4 = [[[FourthViewController alloc] initWithNibName:#"FourthViewController" bundle:nil] autorelease];
UIViewController *viewController5 = [[[FivfthViewController alloc] initWithNibName:#"FivfthViewController" bundle:nil] autorelease];
/* Initialize navigation controllers */
UINavigationController * navigationController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
UINavigationController * navigationController2 = [[UINavigationController alloc] initWithRootViewController:viewController2];
UINavigationController * navigationController3 = [[UINavigationController alloc] initWithRootViewController:viewController3];
UINavigationController * navigationController4 = [[UINavigationController alloc] initWithRootViewController:viewController4];
UINavigationController * navigationController5 = [[UINavigationController alloc] initWithRootViewController:viewController5];
/* Release View Controllers */
[viewController1 release];
[viewController2 release];
[viewController3 release];
[viewController4 release];
[viewController5 release];
/* Stuff Navigation Controllers into return value */
retval = [NSArray arrayWithObjects:viewController1,viewController2,viewController3,viewController4,viewController5,nil];
/* Release Navigation Controllers */
[navigationController1 release];
[navigationController2 release];
[navigationController3 release];
[navigationController4 release];
[navigationController5 release];
return (retval);
}
You Can Try This ....
Yes Howard, your approach is fine. Apple says this too. I also follow same approach while working with UITabbarController with UINavigationController and it works great for me.
You should have one UINavigationController per tab of your TabBarController. So your 2nd approach is correct. I don't think that you can reuse the same navigation controller for all the tabs.
Yes your approach is correct.
If u have to navigate views into tab then that tab should have navigation Controller.
UINavigationController * navigationCtrl = [[UINavigationController alloc] initWithRootViewController:firstTabViewCtrl];
[arrTabs addObject:navigationCtrl];
Either wise there is no need of navigation Controller inside tab.
[arrTabs addObject:firstTabViewCtrl];