选定后更多的NavigationController图像消失 [英] MoreNavigationController images disappearing on select

查看:45
本文介绍了选定后更多的NavigationController图像消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITabBarController,它是通过编程方式创建的,具有6个选项卡.这样,会自动创建MoreNavigationController来照顾超过5个选项卡.显示MoreNavigationController时,一切看起来都很好,但是当我选择这些行之一以将视图控制器推入堆栈时,单元格图像(标签栏图像)消失了.当我弹出该视图控制器时,该图像将保持隐藏状态,直到弹出动画完成为止,这时该图像突然再次出现.

I have a UITabBarController which has been created programatically, which has 6 tabs. As such the MoreNavigationController is automatically created to take care of having more than 5 tabs. Everything looks fine when the MoreNavigationController is displayed, but when I select one of these rows to push the view controller on to the stack, the cell image (tab bar image) disappears. When I pop that view controller, the image remains hidden until the pop animation is completed, at which point the image suddenly appears again.

这是相当老的代码,这些天我不会这样做,但是除了最后一件小事之外,其他所有东西都起作用,所以我很犹豫地删除所有代码并以另一种方式来做.谁能建议我可能做错了什么?

This is fairly old code and I wouldn't do it this way these days, but everything works except for this last little thing so I'm pretty hesitant to rip out all the code and do it another way. Can anyone suggest what I might be doing wrong?

创建其中一个标签栏视图控制器的示例:

An example of creating one of the tab bar view controllers:

InfoViewController* infoViewController = [[InfoViewController alloc] init];
infoViewController.tabBarItem.image = [UIImage imageNamed:@"90-life-buoy.png"];
infoViewController.tabBarItem.title = @"More Info";
infoViewController.title = @"More Info";
UINavigationController* infoNavController = [[UINavigationController alloc] initWithRootViewController:infoViewController];
[infoViewController release];

创建标签栏:

tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects:outdoorsNavController, peopleNavController, citiesNavController, landscapesNavController, infoNavController, basicsNavController, nil];
[window addSubview:tabBarController.view];

无论我是否使用视网膜(@ 2x)图像,似乎都没有任何区别.

Doesn't seem to make any difference whether I use retina (@2x) images or not.

推荐答案

问题是因为您要将InfoViewController包装在UINavigationController中.

The issue is because you're wrapping your InfoViewController in a UINavigationController.

当您单击MoreNavigationController中的表行时,控制器在进行转换时将使用UINavigationController中的tabBarItem.因为这是零(在您的代码中),所以MoreNavigationController中的图像消失了.当转换最终完成时,MoreNavigationControllerInfoViewController

When you click on the table row in MoreNavigationController, the controller uses the tabBarItem in UINavigationController while it does its transition. Because this is nil (in your code), the image in MoreNavigationController disappears. When the transition finally finishes, MoreNavigationController picks up the tabBarItem in InfoViewController

尝试一下:

InfoViewController* infoViewController = [[InfoViewController alloc] init];
infoViewController.tabBarItem.image = [UIImage imageNamed:@"90-life-buoy.png"];
infoViewController.tabBarItem.title = @"More Info";
infoViewController.title = @"More Info";
UINavigationController* infoNavController = [[UINavigationController alloc] initWithRootViewController:infoViewController];
//Set the tabBarItem for UINavigationController
infoNavController.tabBarItem = infoViewController.tabBarItem
[infoViewController release];

以下是一个视频复制并解决了该问题: 项目7的tabBarItem.image设置为空,而项目6的tabBarItem.image设置为

Here's a video reproducing and fixing the issue: Item 7 has an empty tabBarItem.image while Item 6 has tabBarItem.image set

这篇关于选定后更多的NavigationController图像消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆