视图隐藏了tabbarcontroller

时间:2011-05-23 13:41:09

标签: iphone objective-c ipad tabbarcontroller

我开发了基于标签的iphone应用程序。 在这方面,我遇到了如下所述的问题:

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

请帮帮我。

2 个答案:

答案 0 :(得分: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个按钮放在其中一个视图中,即导航控制器 希望这会有所帮助。

答案 1 :(得分:1)

典型的应用程序导航允许用户在标签之间自由地向前和向后移动等。通过在导航栏堆栈上推送和弹出ViewController,可以实现这一点。

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

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

如果您只使用presentModalViewController,因为您想要一个自下而上的动画,那么您将需要使用自定义动画。

相关问题