Ios UITabBarController在更多导航控制器中暂时缺少项目标题和图像
“你有过这样的经历吗?” (注意:以下是ARC友好代码,因此没有Ios UITabBarController在更多导航控制器中暂时缺少项目标题和图像,ios,ios4,uiviewcontroller,uitabbarcontroller,uitabbaritem,Ios,Ios4,Uiviewcontroller,Uitabbarcontroller,Uitabbaritem,“你有过这样的经历吗?” (注意:以下是ARC友好代码,因此没有自动释放调用或保留/释放对。) 所以。。。这是UINavigationController中的顶部UIViewController,它在某个索引处依次位于uitabarcontroller中。Cocoa视图控制器的经典turducken,如果您愿意的话 点击选项卡栏项,上下文将更改为顶部的UIViewController,生活将变得精彩 啊,但是如果您想以编程方式从另一个(选项卡栏)索引下的视图控制器切换到它呢 看起来很容易。只需使
自动释放
调用或保留
/释放
对。)
所以。。。这是UINavigationController中的顶部UIViewController,它在某个索引处依次位于uitabarcontroller中。Cocoa视图控制器的经典turducken,如果您愿意的话
点击选项卡栏项,上下文将更改为顶部的UIViewController,生活将变得精彩
啊,但是如果您想以编程方式从另一个(选项卡栏)索引下的视图控制器切换到它呢
看起来很容易。只需使用-selectedViewController:
,并传入要切换到的UINavigationController(而不是UIViewController)。“基本上是无害的。”
每次都是这样。。。除了当UINavigationController藏在臭名昭著的More导航控制器下面时(iOS在有五个以上的选项卡栏项目时使用),我会遇到一个非常恼人的怪癖
怪癖?当我点击后退按钮(“更多”)以弹出UIViewController(由于更多的位置,它不再是最上面的,你看),表视图单元格中标识此选项卡栏项的imageView
和textLabel
丢失了!就像不在那里一样。只是一个空牢房
如果我将“表格视图”单元格滚动到屏幕外并重新打开,或以其他方式从“更多导航”控制器移开并移回“更多导航”控制器,则会显示:(
发生了什么事?好奇的人想知道…我做了一个修复。它不漂亮,但很了不起 扩展UITABBARC控制器:
- (void)viewDidLoad {
[super viewDidLoad];
self.moreNavigationController.delegate = self;
}
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
//Fix for not showing the selected item in the tableview.
if ([navigationController.topViewController isKindOfClass:NSClassFromString(@"UIMoreListController")]) {
[navigationController.topViewController.view.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[UITableView class]]) {
*stop = YES;
UITableView *tableView = (UITableView *)obj;
[tableView reloadData];
}
}];
}
}
这样,tableview将在可见时重新加载。您将看到单元格出现在转换中,但这对我来说不是问题。这是一个老问题,但我也遇到了同样的问题。您找到解决方案了吗?遗憾的是,还没有。我仍然感谢ping。
- (void)viewDidLoad {
[super viewDidLoad];
self.moreNavigationController.delegate = self;
}
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
//Fix for not showing the selected item in the tableview.
if ([navigationController.topViewController isKindOfClass:NSClassFromString(@"UIMoreListController")]) {
[navigationController.topViewController.view.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[UITableView class]]) {
*stop = YES;
UITableView *tableView = (UITableView *)obj;
[tableView reloadData];
}
}];
}
}