视图隐藏了 tabbarcontroller

发布于 2024-11-09 15:30:45 字数 214 浏览 0 评论 0原文

我开发了一个基于选项卡的 iPhone 应用程序。 在此,我面临如下所述的问题:

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

请帮帮我。

I have developed a tab based iphone application.
In this, I am facing a problem as described below:

The view associated with 1st tab bar contains 2-3 buttons. Action of these buttons are to load another view. Now on pressing these buttons the views are loading but in full size(320x480) and hiding the tab bar.
I want to load that view just above the tab bar so that tab bar is accessible.
I explicitly set the view frame in that view's viewDidLoad function, but it is not working.

Please help me out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

昔日梦未散 2024-11-16 15:30:45

试试这个:

您需要从基于视图的应用程序开始。然后在 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 个按钮放置在导航控制器的视图之一中。
希望这有帮助。

Try this :

You need to start with view based application. And then create a UITabbarController in you appDelegate file.

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];    

You can accordingly manage in which tab you want to place navigation controller or only a view controller.

Then in each of the view controllers mentioned above you need to implement

- (id)init {}

in which you can set Tab name and image.
Rename the tbs as per your requirement. Place 2 buttons in the one of the views which is Navigation controller.
Hope this helps.

千里故人稀 2024-11-16 15:30:45

典型的应用程序导航允许用户在选项卡之间自由地前后移动。这是通过在导航栏堆栈上推送和弹出 ViewController 来实现的。

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

来看,你正在执行导航而不是模态任务,因此我可以建议使用pushViewController而不是presentModalViewController吗?

如果您仅使用presentModalViewController,因为您想要从下到上的动画,那么您将需要使用自定义动画。

Typical application navigation allows the user to freely move forwards and backwards, between tabs etc. This is facilitated by pushing and popping ViewController's on the navigation bar stack.

In certain scenarios you want to force the user to complete some task and this is when you should use a modal view controller. When the application presents a modal view the idea is that the user should NOT be able to navigate away from the view, instead they should only be able to complete or cancel the action and hence the default behavior for a modal view is to hide the navigation bar, tab bar etc.

It sounds to me from your description that you are performing navigation and not a modal task and thus can I recommend using pushViewController instead of presentModalViewController?

If you are only using presentModalViewController because you want a bottom to top animation then you'll need to use a custom animation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文