“隐藏”推送视图时的选项卡栏

发布于 2024-08-08 19:45:49 字数 166 浏览 0 评论 0原文

纽约时报 iPhone 应用程序有一个带有五个选项卡栏项目的选项卡栏。当您选择“最新”选项卡时,应用程序会在 UITableView 中显示标题和摘要/摘要。当您选择要阅读的单个故事时,选项卡栏会消失,并替换为页眉和页脚,页眉和页脚的显示/消失取决于应用程序的状态。应用程序如何“隐藏”标签栏?

谢谢!

The New York Times iPhone application has a Tab Bar with five tab bar items. When you select the Latest tab, the app shows the title and abstract/summary in a UITableView. When you select an individual story to read, the Tab Bar disappears and is replaced with a header and footer that appears/disappears depending on the state of the app. How does the app "hide" the tab bar?

Thanks!

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

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

发布评论

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

评论(3

清泪尽 2024-08-15 19:45:49

在要隐藏选项卡栏的类中实现这段代码。

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
    // Custom initialization
}
self.hidesBottomBarWhenPushed = YES;
return self;
}

一切顺利。

Implement this piece of code in the class where you want to hide the Tab Bar.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
    // Custom initialization
}
self.hidesBottomBarWhenPushed = YES;
return self;
}

All the best.

谎言月老 2024-08-15 19:45:49

被推送到导航控制器堆栈上的视图控制器的 hidesBottomBarWhenPushed 参数设置为 yes。代码在表视图的 -didSelectRowAtIndexPath 中看起来像这样。

NSDictionary *newsItem = [newsItems objectAtIndex:[indexPath row]];
NewsDetailViewController *controller = [[NewsDetailViewController alloc] init];
[controller setHidesBottomBarWhenPushed:YES];
[controller setNewsItem:newsItem];
[[self navigationController] pushViewController:controller animated:YES];
[controller release], controller = nil;

看看 hidesBottomBarWhenPushed 的文档

ps 如果您向此问题添加标签“iphone”,您可能会更清楚地了解该问题。

The view controller that is being pushed onto the navigation controller stack has its hidesBottomBarWhenPushed parameter set to yes. The code would look something like this in the table view's -didSelectRowAtIndexPath.

NSDictionary *newsItem = [newsItems objectAtIndex:[indexPath row]];
NewsDetailViewController *controller = [[NewsDetailViewController alloc] init];
[controller setHidesBottomBarWhenPushed:YES];
[controller setNewsItem:newsItem];
[[self navigationController] pushViewController:controller animated:YES];
[controller release], controller = nil;

Take a look at the documentation for hidesBottomBarWhenPushed.

p.s. You'll probably get more visibility on this question if you add the tag 'iphone' to it.

抹茶夏天i‖ 2024-08-15 19:45:49

我有一个视图需要选择(取决于其他状态)显示导航控制器工具栏。这是我用来展示和展示的解决方案当视图出现时隐藏工具栏(带动画)通过导航消失。听起来像是您可能想要的。

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    // Show the nav controller toolbar if needed
    if (someBool)
        [self.navigationController setToolbarHidden:NO animated:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    // Hide the nav controller toolbar (if visible)
    [self.navigationController setToolbarHidden:YES animated:animated];
}

I have a view that needs to optionally (depending on some other state) show the navigation controller toolbar. This is the solution I used to show & hide the toolbar (with animation) when the view appears & disappears via navigation. It sounds like what you might be after.

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    // Show the nav controller toolbar if needed
    if (someBool)
        [self.navigationController setToolbarHidden:NO animated:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    // Hide the nav controller toolbar (if visible)
    [self.navigationController setToolbarHidden:YES animated:animated];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文