开发者

UITabBar does not display

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 meth开发者_JS百科od 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


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];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜