如何在基于视图/选项卡栏的应用程序中隐藏选项卡栏

发布于 2024-11-06 23:14:53 字数 1237 浏览 0 评论 0原文

我正在开发一个简单的基于视图的 iPhone 应用程序。 从应用程序的主屏幕,您可以导航到 4 个不同的视图。 这些视图之一包含一个选项卡栏。 因为这不是正常方法,所以我使用了没有 UITabController 的解决方法。

为了实现这一点,我利用了这个主题: https://discussions.apple.com/thread/2099944?start=0& ;tstart=0

这个示例代码: http://pymbian.svn.sourceforge.net/svnroot/pymbian/ stuff/testtab_raynewbie/Classes/

通过一些小的修改就可以了。 只有当我想从选项卡式视图返回主视图时,我有最后一个错误,选项卡栏保留在屏幕底部。

我尝试了这里描述的几种方法。

myTabBar.hidden = YES
hidesBottomBarWhenPushed = YES

但似乎没有一个起作用...... 我认为问题出在视图 UI 控制器的奇怪结构中。因为现在的结构是这样的。

MainViewController
- ViewController with TabBar
  - tab1viewcontroller
  - tab2viewcontroller
- other viewcontrollers

返回主视图是在 tab1viewcontroller 中完成的,我无法对 TabBar 执行任何操作。在所有其他视图中,我都会返回以下代码:

-(IBAction) BackAction:(id)sender {

mainControllerView = [[MainControllerView alloc] initWithNibName:@"MainControllerView" bundle:nil];
[self.view addSubview:mainControllerView.view];
[mainControllerView.view release];

}

有人有想法吗?

I'm working at a simple view-based iPhone application.
From the main screen of the App you can navigate to 4 different views.
One of these views consists of a tab bar.
Because this is not the normal approach I used a workaround without a UITabController.

To accomplish this I made use of this topic:
https://discussions.apple.com/thread/2099944?start=0&tstart=0

And this example code:
http://pymbian.svn.sourceforge.net/svnroot/pymbian/stuff/testtab_raynewbie/Classes/

With some small modifications this works.
Only I have one last bug when I want to return to the home view from the tabbed view, the tab bar stays in the bottom of the screen.

I tried several approaches described here.

myTabBar.hidden = YES
hidesBottomBarWhenPushed = YES

But none seem to work....
I think the problem is somewhere in the strange structure of views UI controllers. Because now the structure looks like this.

MainViewController
- ViewController with TabBar
  - tab1viewcontroller
  - tab2viewcontroller
- other viewcontrollers

And going back to the main view is done in the tab1viewcontroller where I can't do anything to the TabBar. In all the other views I go back with this code:

-(IBAction) BackAction:(id)sender {

mainControllerView = [[MainControllerView alloc] initWithNibName:@"MainControllerView" bundle:nil];
[self.view addSubview:mainControllerView.view];
[mainControllerView.view release];

}

Anyone an idea?

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

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

发布评论

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

评论(2

疯了 2024-11-13 23:14:53

从上一个视图推送时,您需要隐藏选项卡栏。

LoginViewController *loginViewObj =[[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
loginViewObj.hidesBottomBarWhenPushed=YES;

LoginViewController 是不需要标签栏时要推送的视图。 :)

You need to hide the tab bar when pushed from previous view.

LoginViewController *loginViewObj =[[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
loginViewObj.hidesBottomBarWhenPushed=YES;

LoginViewController is the view to be pushed where tab bar is not required. :)

岁月苍老的讽刺 2024-11-13 23:14:53

尝试在要隐藏选项卡栏的视图控制器中执行以下

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [self.tabBarController.view setFrame:CGRectMake(0, 0, 320, 560)];
}

代码

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    [self.tabBarController.view setFrame:CGRectMake(0, 0, 320, 480)];

}

Try following code in view-controller where you want to hide tabbar

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [self.tabBarController.view setFrame:CGRectMake(0, 0, 320, 560)];
}

and

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    [self.tabBarController.view setFrame:CGRectMake(0, 0, 320, 480)];

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