从“更多”中隐藏标题标签栏控制器中的导航栏一致

发布于 2024-12-11 08:36:25 字数 876 浏览 0 评论 0原文

我有以下问题。

我的 UINavigationBar 有一个背景图像,因此我必须隐藏导航栏中的所有标题。问题出在 TabBarController 的“更多”导航栏上。我已经设法隐藏它,但这只会在第一次显示时发生。当我从其中选择一个项目并返回时,会再次显示“更多”。

我猜我应该禁用“更多”视图控制器的某种“viewWillAppear”委托方法中的标题,但我不知道该怎么做。

这是我第一次显示“更多”,正如你所看到的,徽标在那里(当然被弄脏了:))但是,更多却没有: http://www.flickr.com/photos/68985587@N02/6272805069/ lightbox/

这是“更多”视图控制器中第一个项目的视图控制器: http://www.flickr.com/photos/68985587@ N02/6272805241/in/photostream/lightbox/

当我按下“更多”左侧按钮后导航栏返回,我得到这个: http://www.flickr.com/photos/68985587@ N02/6273332152/in/photostream/lightbox/

感谢您的帮助!

I have the following issue.

I have a background image for my UINavigationBar so I have to hide all the titles from the Navigation Bars. The problem comes with the "More" Navigation Bar of the TabBarController. I have managed to hide it, but this only happens the first time its shown. When I select an item from within it, and go back, "More" is displayed again.

Im guessing I should disable the title inside some sort of "viewWillAppear" delegate method for the "More" View Controller, yet I have no idea how to do that.

This is the first time I display "More", as you can see, the Logo is there (smudged of course :) ) however, More is not:
http://www.flickr.com/photos/68985587@N02/6272805069/lightbox/

This is the View Controller of the first Item in the "More" View Controller:
http://www.flickr.com/photos/68985587@N02/6272805241/in/photostream/lightbox/

After I press the "More" left button in the Navigation Bar to go back, I get this:
http://www.flickr.com/photos/68985587@N02/6273332152/in/photostream/lightbox/

Thanks for your help!

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

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

发布评论

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

评论(4

太傻旳人生 2024-12-18 08:36:25

解决方案是将委托设置为更多视图控制器并根据委托方法进行操作。

首先,我将委托设置为“更多”视图控制器(在我的例子中是在应用程序委托中):

[tbc.moreNavigationController setDelegate:self];

我继续实现以下方法:

-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if([viewController.title isEqualToString:@"More" ])
    {
        UILabel *label = [[[UILabel alloc] init] autorelease];
        viewController.navigationItem.titleView = label;
        label.text = @"";   
    }

}

这不仅在第一次而且每次视图控制器出现时都会有效地被调用。即使按下后退按钮。

The solution came by setting the delegate to the more view controller and acting upon the delegate method.

First, I set the delegate to the "more" view controller (in my case in the appdelegate):

[tbc.moreNavigationController setDelegate:self];

the I proceeded to implement the following method:

-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if([viewController.title isEqualToString:@"More" ])
    {
        UILabel *label = [[[UILabel alloc] init] autorelease];
        viewController.navigationItem.titleView = label;
        label.text = @"";   
    }

}

This effectively gets called not just the first time but everytime the view controller came up. Even when a back button was pressed.

错々过的事 2024-12-18 08:36:25

您可以通过实现UITabBarDelegate的委托方法tabBar:didSelectItem:来检查UITabBarController的哪个选项卡被点击。如果单击第五项(“更多”项),那么您可以这样设置标题:

[[[tabBarController moreNavigationController] visibleViewController] setTitle:@""];

我希望,它有效,我还没有尝试过。祝你好运!

You can check what tab of the UITabBarController was clicked by implementing the delegate method tabBar:didSelectItem: of UITabBarDelegate. If the fifth item (the "More" item) was clicked, then you can set the title like this:

[[[tabBarController moreNavigationController] visibleViewController] setTitle:@""];

I hope, it works, I haven't tried it. Good luck!

违心° 2024-12-18 08:36:25

我建议您查看此链接此处< /a> 和 此处

Hig,根据超过 5不建议使用图标。您可以搜索 TabBar 的链接。

I suggest you to look at this link here and here

Hig, according to more than 5 icons are not recommended for use. You can search links for TabBar.

红墙和绿瓦 2024-12-18 08:36:25

您可以替换标签:

UITabBarItem *i = self.tabBarController.tabBar.items[4];
[i setTitlePositionAdjustment:UIOffsetMake(0., 300.)];

因此它与顶部有一个偏移量,使其消失......

You can displace the label:

UITabBarItem *i = self.tabBarController.tabBar.items[4];
[i setTitlePositionAdjustment:UIOffsetMake(0., 300.)];

so it has an offset from top that let it disappear...

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