vikramarkaios vikramarkaios - 6 months ago 20
Objective-C Question

Add tabbar in Home page in Objective c

I need to develop for my project for firstly coming splash screen after then Home scree. In that home screen contains Tabbar in bottom side. Please suggest any one. How to proceed. I need programatically

Answer

So, if you want to create a tabbar on a specific view controller:

on ViewController.h:

@property (nonatomic, retain) UITabBarController *tab;

on ViewController.m

self.tab = [UITabBarController new];

// FirstViewController
FirstViewController *vc1=[[FirstViewController alloc] initWithNibName:nil bundle:nil];
vc1.title=@"First View Controller";
vc1.tabBarItem.image = [UIImage imageNamed:@"viewcontroller1.png"];

//SecondViewController
SecondViewController *vc2 = [[SecondViewController alloc]initWithNibName:nil bundle:nil];
vc2.title=@"Second";
vc2.tabBarItem.image = [UIImage imageNamed:@"viewcontroller2.png"];

self.tab.viewControllers = @[vc1, vc2];

[self.view addSubview:self.tab.view];
Comments