我开发了一个基于标签的 iphone 应用程序。在这方面,我面临如下所述的问题:
与第一个标签栏关联的视图包含 2-3 个按钮。这些按钮的作用是加载另一个视图。现在按下这些按钮,视图正在加载,但全尺寸(320x480)并隐藏标签栏。我想在标签栏上方加载该视图,以便可以访问标签栏。我在该视图的 viewDidLoad 函数中明确设置了视图框架,但它不起作用。
请帮帮我。
我开发了一个基于标签的 iphone 应用程序。在这方面,我面临如下所述的问题:
与第一个标签栏关联的视图包含 2-3 个按钮。这些按钮的作用是加载另一个视图。现在按下这些按钮,视图正在加载,但全尺寸(320x480)并隐藏标签栏。我想在标签栏上方加载该视图,以便可以访问标签栏。我在该视图的 viewDidLoad 函数中明确设置了视图框架,但它不起作用。
请帮帮我。
尝试这个 :
您需要从基于视图的应用程序开始。然后在你的 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 个按钮。
希望这可以帮助。
典型的应用程序导航允许用户在选项卡之间自由地向前和向后移动。这可以通过在导航栏堆栈上推送和弹出 ViewController 来促进。
在某些情况下,您希望强制用户完成某些任务,此时您应该使用模态视图控制器。当应用程序呈现模态视图时,想法是用户不应该能够离开视图,而是只能完成或取消操作,因此模态视图的默认行为是隐藏导航栏,标签栏等
从您的描述中听起来,您正在执行导航而不是模态任务,因此我可以推荐使用 pushViewController 而不是 presentModalViewController 吗?
如果您只使用 presentModalViewController 是因为您想要一个从下到上的动画,那么您需要使用自定义动画。