【问题标题】:UITabBarController moreNavigationController as a grouped TableView?UITabBarController moreNavigationController作为一个分组的TableView?
【发布时间】:2011-02-24 22:18:21
【问题描述】:
我使用的 UITabBarController 有超过 5 个项目,因此它显示更多选项卡。
是否可以让这个moreNavigationController成为一个分组的TableView(uitableviewstylegrouped)?目前它默认为普通的表格视图。
【问题讨论】:
标签:
uitabbarcontroller
uitableview
【解决方案1】:
尝试准确地给出 5,而不是超过 5,让第 5 个成为分组表视图控制器的主机
【解决方案2】:
下面的代码 sn-p 正是这样做的。它使用 UITabBarController 的实例(这里称为控制器)通过 UITabBarController moreNavigationController 属性访问导航栏和 tableview 控制器。
#define BACKGROUNDCOLOUR [UIColor colorWithRed:253.0/255.0 green:255.0/255.0 blue:240.0/255.0 alpha:1.0]
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//... other init code
UINavigationBar *moreNavBar = controller.moreNavigationController.navigationBar;
moreNavBar.tintColor = [UIColor blackColor];
UITableView *moreTableView = (UITableView *)controller.moreNavigationController.topViewController.view;
[moreTableView initWithFrame:CGRectZero style:UITableViewStyleGrouped];
[moreTableView setBackgroundColor:BACKGROUNDCOLOUR];
[self.window addSubview:controller.view];
[self.window makeKeyAndVisible];
return YES;
}