1. AppDelegate.h
Define Tabbarcontroller
#import <UIKit/UIKit.h>
@interface appdelegate:uiresponder <uiapplicationdelegate>
@property (Strong, nonatomic) uiwindow *window;
@property (Strong, nonatomic) uitabbarcontroller *tabbarcontroller;
@end
2.appdelegate.m
#import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
@interface appdelegate () <uitabbarcontrollerdelegate>
@end
@implementation appdelegate
-(BOOL) application: (uiapplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchoptions {
self. Window = [[uiwindow alloc]initwithframe: [[uiscreen mainscreen]bounds]];/ /Instantiate window
self. Window. backgroundcolor = [Uicolor whitecolor];//setting window background
_tabbarcontroller = [[Uitabbarcontroller alloc]init];//Instantiate tab Controller
_tabbarcontroller. Delegate = self;//Set Appdelegate as the proxy for the tab controller???
Instantiation of 3 controllers
Firstviewcontroller *firstviewcontroller = [[Firstviewcontroller alloc]initwithnibname: @ "Firstviewcontroller" bundle:nil];
Secondviewcontroller *secondviewcontroller = [[Secondviewcontroller alloc]initwithnibname :@ "Secondviewcontroller" bundle:nil];
Thirdviewcontroller *thirdviewcontroller = [[Thirdviewcontroller alloc]initwithnibname: @ "Thirdviewcontroller" bundle:nil];
Instantiate 3 navigators and place each controller's object in the Navigator's method with the controller
Uinavigationcontroller *navfirst = [[Uinavigationcontroller alloc] Initwithrootviewcontroller: Firstviewcontroller];
Navfirst. title = @ " take time ";
Uinavigationcontroller *navsecond = [[uinavigationcontroller alloc]initwithrootviewcontroller: Secondviewcontroller];
Navsecond. title = @ " Flower members ";
Uinavigationcontroller *navthird = [[Uinavigationcontroller alloc]Initwithrootviewcontroller : Thirdviewcontroller];
Navthird. title = @ " i ";
//Place the Navigator object in the sub-controller (viewcontroller) of the tab
_tabbarcontroller. Viewcontrollers = [nsarray Arraywithobjects:navfirst,navsecond,navthird, Nil];
//Set UIWindow Rootviewcontroller to Uitabbarcontroller
_window. Rootviewcontroller = _tabbarcontroller;
[self. Window makekeyandvisible];
return YES;
}
3. Set Tabbaritem title for each Uiviewcontroller
Firstviewcontroller.m
#import "FirstViewController.h"
#import "AppDelegate.h"
@interface firstviewcontroller () <uitableviewdatasource, uitableviewdelegate>{
Nsmutablearray *_allflowers;
}
@end
@implementation Firstviewcontroller
-(ID) initwithnibname: (NSString *) Nibnameornil Bundle: (nsbundle *) nibbundleornil{
Self = [super Initwithnibname:nibnameornil Bundle:nibbundleornil];
if (self) {
self. Tabbaritem. Image = [UIImage imagenamed:@ "First.png"];
self. Tabbaritem. Title = @ " take time ";
self. Navigationitem. Title = @ " take time ";
}
return self;
}
Tabbar Implement page jumps (appdelegate +navigationviewcontroller + tabbarviewcontroller)