基于导航的项目中的uitabbarcontroller / uitabbar [英] uitabbarcontroller / uitabbar in navigation based project

查看:86
本文介绍了基于导航的项目中的uitabbarcontroller / uitabbar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了基于导航的项目。在第二个屏幕中,我想添加uitabbarcontroller。所以任何人都可以建议我这样做。

I have created navigation based project. and in second screen i want to add uitabbarcontroller. so can any one suggest how i do this.

我已经做了很多搜索,但还没有成功。所以请您提供一个简单的样本。我已经尝试过以下讨论,但我认为这不是一个好方法。

i already did lot of search but no success yet. so please can you provide a simple sample of this. i already tried below discussion but i think its not a good approach.

使用TabBar导航应用程序

谢谢

推荐答案

实际上这是正确的做法。不正确的一件事是分配控制器的地方。这发生在前一个控制器中,正在进行推送,但应该在负责的对象中分配,TabBarController。

Actually this is the correct approach. The one thing that is not correct is where the controllers are allocated. This is happened in the previous controller, the one that is making the push, but should be allocated in the object that is responsible, the TabBarController.

当你实现你的行动时显示UITabBarController生成以下代码:

When you implement your action to show the UITabBarController make the following code:

- (void) theAction {
   SomeTabBarControllerSubClass *controller = [[SomeTabBarControllerSubClass alloc] init];
   [self.navigationController pushViewController:controller animated:YES];
   [controller release];
}

然后当你实现SomeTabBarControllerSubClass类时:

(.h)

Then when you implement the SomeTabBarControllerSubClass class:
(.h)

@interface SomeTabBarControllerSubClass : UITabBarController {
   UIViewController *first;
   UIViewController *second;
}

@end

(。m)

@implementation SomeTabBarControllerSubClass

- (void) viewDidLoad {
   first = [[UIViewController alloc] init]; //Or initWithNib:
   second = [[UIViewController alloc] init];

   first.view.backgroundColor = [UIColor greenColor] //Just example
   second.view.backgroundColor = [UIColor redColor] //Just example
   first.tabBarItem.image = [UIImage imageNamed:@"someImage.png"];

   self.viewControllers = [NSArray arrayWithObjects:first,second,nil];
}

- (void) dealloc {
   [first dealloc];
   [second dealloc];
   [super dealloc];
}

@end

这篇关于基于导航的项目中的uitabbarcontroller / uitabbar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆