问题描述
|
我已经开发了基于标签的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 {}
您可以在其中设置标签页名称和图像。
根据您的要求重命名tb。将2个按钮放在其中一个视图中,即导航控制器。
希望这可以帮助。
,典型的应用程序导航允许用户在选项卡等之间自由地前后移动。通过在导航栏堆栈中推入和弹出ViewController可以方便地进行此操作。
在某些情况下,您想强制用户完成某些任务,这是您应该使用模式视图控制器的时候。当应用程序提供模式视图时,其想法是用户不应能够离开视图,而只能完成或取消操作,因此模式视图的默认行为是隐藏导航栏,标签栏等
从您的描述中,我听起来您是在执行导航而不是模态任务,因此我可以建议使用pushViewController代替presentModalViewController吗?
如果您只想使用从下到上的动画,而只使用presentModalViewController,那么您将需要使用自定义动画。