2011-05-23 85 views
0

我开发了一个基于标签的iphone应用程序。 在此,我遇到如下所述的问题:视图隐藏tabbarcontroller

与第一个标签栏关联的视图包含2-3个按钮。这些按钮的动作是加载另一个视图。现在按下这些按钮,视图正在加载,但以全尺寸(320x480)并隐藏标签栏。 我想在标签栏上方加载该视图,以便可以访问标签栏。 我明确地在该视图的viewDidLoad函数中设置了视图框架,但它不起作用。

请帮我一把。

+0

您是否在展示视图? – nambi 2011-05-23 13:45:28

+0

ya使用以下代码呈现视图:Cities * cv = [[Cities alloc] initWithNibName:@“Cities”bundle:nil]; \t cv.modalTransitionStyle = UIModalTransitionStyleCoverVertical; \t [self presentModalViewController:cv animated:YES]; \t \t [cv release]; – 2011-05-23 13:46:35

+0

是否有你没有/不能将视图控制器推到导航栈上的原因? – 2011-05-23 14:10:52

回答

1


试试这个:

你需要开始与视图基础的应用。然后在你的appDelegate文件中创建一个UITabbarController

Appdelegate.h

UITabBarController *tabBarController; 
// set properties 

Appdelegate.m 

// Synthsize 

tabBarController = [[UITabBarController alloc] init]; 
tabBarController.delegate=self; 

//Adding Search,Nearby,Map,AboutUs,Favorites Tabs to tabBarController 
Search * search = [[Search alloc] init]; 
UINavigationController *searchNav = [[UINavigationController alloc] initWithRootViewController:search]; 

Nearby* nearby = [[Nearby alloc] init]; 
UINavigationController *nearbyNav = [[UINavigationController alloc] initWithRootViewController:nearby]; 

Map* map = [[Map alloc] init]; 
UINavigationController *mapNav = [[UINavigationController alloc] initWithRootViewController:map]; 

AboutUs* aboutUs = [[AboutUs alloc] init]; 
UINavigationController *aboutUsNav = [[UINavigationController alloc] initWithRootViewController:aboutUs]; 

Favorites* favorites = [[Favorites alloc] init]; 
UINavigationController *favoritesNav = [[UINavigationController alloc] initWithRootViewController:favorites]; 

NSArray* controllers = [NSArray arrayWithObjects:searchNav,nearbyNav,mapNav,aboutUsNav,favoritesNav, nil]; 
tabBarController.viewControllers = controllers; 

[window addSubview:tabBarController.view];  

您可以相应地管理其标签要放置导航控制器或只有一个视图控制器。

在上述各你所提到的视图控制器的

然后需要实现

- (id)init {} 

,可以在其中设置选项卡名称和图像。 根据您的要求重新命名tbs。将2个按钮放置在导航控制器的其中一个视图中。
希望这会有所帮助。

+0

但是在这里,我通过IB完成的每一件事......现在根据我的要求,视图上会有一个按钮,分别与第一个标签栏以及按下该按钮的另一个视图将加载...。现在的问题是,这个加载的视图加载到整个屏幕,以便tabbarcontroller隐藏...。 – 2011-05-24 05:36:27

+0

我总是喜欢使用代码而不是IB。只需检查您是否正确添加了导航栏和tabbar控制器中的视图。您可能会在某个地方添加第二个视图,即在tabbar中单击按钮时显示的视图。 – Nitish 2011-05-24 05:42:54

1

典型的应用程序导航允许用户在标签等之间自由地前后移动。推动并弹出导航栏堆栈上的ViewController可以方便实现。

在某些情况下,你想强制用户完成一些任务,这是你应该使用模态视图控制器。当应用程序呈现模态视图时,这个想法是用户不应该能够离开视图,而应该只能够完成或取消该操作,因此模态视图的默认行为是隐藏导航酒吧,标签栏等

从你的描述中,我听起来对我来说,你正在执行导航,而不是模态任务,因此我可以推荐使用pushViewController而不是presentModalViewController吗?

如果您只使用presentModalViewController,因为您需要从底部到顶部的动画,那么您需要使用自定义动画。