0
votes

Hi i am working on an application which has a login form and another view called as Invitation. Now heres my problem in my Login view on the hit of Login button i am coming to the Invitation View with the help of the code which looks like this

    -(void)buttonPress
{
    Invitation *obj = [[Invitation alloc]init];
    [self.navigationController pushViewController:obj animated:YES];

}

Now in the Invitation view what happens is that i want a tabbar to be displayed so i wrote a code which looks like this

objTabbar = [[UITabBar alloc]init];
    HomeItem = [[UITabBarItem alloc]initWithTitle:@"Home" image:[UIImage imageNamed:@"house.png"] tag:0];
    BluetoothItem = [[UITabBarItem alloc]initWithTitle:@"Bluetooth" image:[UIImage imageNamed:@"bluetooth.png"] tag:1];
    NSArray *a = [[NSArray alloc]initWithObjects:HomeItem,BluetoothItem,nil];
    objTabbar.items = a;

and in the LoadView method i did this

- (void)loadView {
[super loadView];

     self.navigationItem.hidesBackButton = YES;
[self.view addSubview:objTabbar];

}

Now the code is building successfully but the problem is that the Tabbar is not getting displayed. I tried tabbarController and did this

tabbarController.view = objTabbar;

and added the tabbarController in the loadView method

[self.view addSubview:tabbarController.view];

But still no success

Please help me out and let me know where am i going wrong Thank You

1
Can you create your TabBar in IB? after that's what IB is for....Richard J. Ross III
@Richard: I i know like i did that but i don't wana use IB, i am trying to do this via code, so Sir do u have any suggestions regarding coding, that would be really helpfulRadix

1 Answers

0
votes

i believe the reason why you are not getting is because you are using the wrong code. Here are few mistakes i would like to point out.

  1. replace objTabbar = [[UITabBar alloc]init]; with

    objTabbar = [[UITabBarController alloc]init];

  2. Replace objTabbar.items = a; with

    [objTabbar setViewControllers:a];