自定义选项卡栏上的“更多”菜单 [英] Customizing the More menu on a Tab bar

查看:115
本文介绍了自定义选项卡栏上的“更多”菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序上使用标签栏(UITabBarController),我希望自定义单击更多按钮时出现的表格外观。
通过设置

I am using a tab bar (UITabBarController) on my app and I wish to customize the appearance of the table that appears when you click the more button. I have worked out how to change the appearance of the Navigation bar that is on the more screen by setting

self.moreNavigationController.navigationBar.barStyle

在UITabBarController的子类中,我设法改变了背景颜色该表通过修改

in a subclass of UITabBarController and I have managed to change the background colour of the table by modifying

self.moreNavigationController.topViewController.view.backgroundColor

,但我无法弄清楚如何更改表格中显示的单元格中的字体颜色。
我希望我可以使用

, but I cannot work out how to change the font colour in the cells that appear on the table. I was hoping I could use

self.moreNavigationController.topViewController.view.visibleCells 

但这似乎总是空的。我已尝试在viewDidLoad,viewWillAppear和viewDidAppear中执行此操作但未成功。对象self.moreNavigationController.topViewController的类型为UIMoreListController,它似乎没有文档,我在界面中看不到任何可以帮助我的东西。

but this always seems to be empty. I've tried doing this in viewDidLoad, viewWillAppear and viewDidAppear with no success. The object self.moreNavigationController.topViewController is of type UIMoreListController, which seems to be undocumented and I can't see anything obvious in the interface that will help me.

任何想法?

推荐答案

只有在显示moreNavigationController后才会填充visibleCells。

visibleCells is populated only after the moreNavigationController is displayed.

并且单元格是在运行时创建的,因此即使您更改单元格的内容,它们也会在显示时被替换。

And the cells are created at runtime, so even if you change the content of the cells, they are replaced when they are displayed.

要尝试的一件事是替换moreNavigationController tableView的数据源,调用原始数据源的cellForRowAtIndexPath并在返回之前更改其内容。

One thing to try would be to replace the datasource of the moreNavigationController tableView, call the cellForRowAtIndexPath of the original datasource and change its content before returning it.

使用下面的代码,在显示一次moreNavigationController之后初始化它,你会看到当你返回到moreNavigationController时,单元格是红色的,但是立即返回到白色背景。

Using the code below, after having displayed once the moreNavigationController to initialize it, you'll see that when you return to the moreNavigationController, the cells are red, but return immediately to white background.

UITableView *view = (UITableView *)self.tabBarController.moreNavigationController.topViewController.view;
if ([[view subviews] count]) {
  for (UITableViewCell *cell in [view visibleCells]) {
    cell.backgroundColor = [UIColor redColor];
  }
}

这篇关于自定义选项卡栏上的“更多”菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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