我正在我的应用程序的 UITabBarController 中自定义“更多” View 。
从我在文档中看到的内容来看,几乎没有对自定义它的支持。 UITabBarController 只有一个名为“moreNavigationController”的只读属性指向 UINavigationController。
这至少允许我们自定义它的 UINavigationBar。自定义它在第一个 View Controller 中呈现的 TableView 有点棘手。
关于 SO 和其他地方的其他问题,我看到所有的讨论都围绕着弄乱 moreNavigationController 的内部结构(例如观察堆栈中的第一个 View Controller 是一个 UITableViewController,换掉它的数据 Controller , ETC。)。问题是所有这些方法都对 API 中未记录的代码的行为方式做出了假设,这些假设很难过时。
我在这里看到的唯一选择是推出我自己的自定义“更多 Controller ”(可选择放弃编辑功能以保持实现相当简单)并将其用作选项卡中的第五个 View Controller 。当然,必须注意将后续 View Controller 分配给自定义的“更多 Controller ”,而不是直接分配给 UITabBarController(可能需要子类化 UITabBarController 才能执行此规则)。
您会选择哪种方法?您会建议哪些其他解决方案?
最佳答案
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!
}
关于iphone - 自定义 UITabBarController 的 moreNavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4389229/