自定义UITabBarController的moreNavigationController [英] Customizing UITabBarController's moreNavigationController

查看:447
本文介绍了自定义UITabBarController的moreNavigationController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在自定义应用程序的UITabBarController中的更多视图。

I'm in the process of customizing the 'More' view in my app's UITabBarController.

根据我在文档中看到的,它。只有UITabBarController的一个只读属性,名为'moreNavigationController',它指向一个UINavigationController。

From what I see in the docs there is precious little support for customizing it. There is only a read-only property of the UITabBarController called 'moreNavigationController' that points to a UINavigationController.

这允许我们至少定制它的UINavigationBar。自定义它在第一个视图控制器中呈现的表视图有点棘手。

This allows us at least to customize it's UINavigationBar. Customizing the table view it presents in the first view controller is a little trickier.

在SO和其他地方的其他问题上,我看到所有的谈话都围绕着与moreNavigationController的内部结构(例如观察到堆栈中的第一个视图控制器是一个UITableViewController,换出它的数据控制器,等等)。问题是所有这些方法假设在API中未记录的代码如何行为,假设是很难面向未来。

On other questions here on SO and elsewhere, I've seen that all talk revolves around messing with the internal structure of the moreNavigationController (for example observing that the first view controller in the stack is a UITableViewController, swapping out it's data controller, etc.). Problem is all these methods make assumptions about how undocumented code in the API behaves, assumptions that are hardly future-proof.

我看到的唯一的选择是滚动我自己自定义更多控制器(可选地,切换编辑功能以保持实现相当简单),并将其用作选项卡中的第五个视图控制器。当然,必须注意将后续的视图控制器分配给自定义的更多控制器,而不是直接分配给UITabBarController(对UITabBarController进行子类化可能需要强制执行此规则)。

The only alternative I see here is to roll my own custom "more controller" (optionally ditching the edit functionality to keep the implementation fairly simple) and using it as the fifth view controller in the tab. Of course care must be taken to assign the subsequent view controllers to the custom "more controller" not to the UITabBarController directly (subclassing the UITabBarController may be required to enforce this rule).

你会选择哪种方法?您会建议什么其他解决方案?

Which approach would you choose? What other solutions would you suggest?

推荐答案

UIViewController *tbMore = 
    ((UIViewController*)
    [self.moreNavigationController.viewControllers objectAtIndex:0]);

int nRows = [((UITableView *)tbMore.view) numberOfRowsInSection:0];

for (int i = 0; i < nRows; i++)
{
    UITableViewCell *c =
        [((UITableView *)tbMore.view)
        cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];

    // Do any additional customization here!
}

这篇关于自定义UITabBarController的moreNavigationController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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