好吧,这是我的问题:我的应用程序在在的iPhoneOS屏幕底部的标签栏类别的显示。这将只允许5个类别它呈现的更多按钮之前。我有超过25(请不要说回答这个问题:“重新考虑你的应用程序...等等” - 这是毫不客气地说,之前他们是食品,饮料等类别,不能更改)。我想允许用户把自己喜爱的主页上。苹果moreNavigationController编辑系统只允许20级标签栏的项目进行重构由于编辑页面上的空间限制。这是不够的,所以我需要实现我自己的编辑屏幕。我设置了rightBarButtonItem为零,创造了我自己。使用的NSLog,我可以看到“点击”发生点击编辑按钮时,但使用pushViewController我不能推。没发生什么事。我认为这是与我解决navigationController ...但我不知道。 PS:这个所有发生在我的应用程序委托它DOES充当两者UITabBarControllerDelegate&UINavigationControllerDelegate

我试图执行以下操作:

 - ( void )navigationController:( UINavigationController * )navigationController_local willShowViewController:( UIViewController * )viewController_local animated:( BOOL )animated
{

    UIViewController * currentController = navigationController_local.visibleViewController;
    UIViewController * nextController = viewController_local;

 // Do whatever here.
 NSLog(@"Nav contoller willShowViewController fired\n'%@'\n'%@'\nThere are currently: %d views on the stack\n",currentController,nextController,[self.navigationController.viewControllers count]);

 if ( [nextController isKindOfClass:NSClassFromString(@"UIMoreListController")])
 {
  UINavigationBar *morenavbar = navigationController_local.navigationBar;
  UINavigationItem *morenavitem = morenavbar.topItem;
  morenavitem.rightBarButtonItem = nil;
  NSLog(@"Is a UIMoreListController\n");

  UIBarButtonItem *editTabBarButton = [[UIBarButtonItem alloc]
             initWithTitle:@"Edit"
             style:UIBarButtonItemStylePlain
             target:self
             action:@selector(editTabBar:)];

  morenavitem.rightBarButtonItem = editTabBarButton;
  [editTabBarButton release];
 }


}

该作品将编辑按钮在屏幕的右上角 - 模仿苹果的外观和感觉...但点击该按钮时,您不能退出织补moreNavigationController

我已经尝试了很多东西。 UIAlerts工作,等等...但推动(或弹出 - 甚至弹出到根视图)。一个视图控制器在堆栈上没有

- (void) editTabBar:(id)sender {
 NSLog(@"clicked edit tabbar\n");
 NSLog(@"Total count of controllers: %d\n",[self.navigationController.viewControllers count]);

 TabBarViewController *tabBarViewController2 = [[TabBarViewController alloc] initWithNibName:@"TabBarView" bundle:nil];
  tabBarViewController2.navigationItem.title=@"Edit Tab Bar";
  [self.navigationController pushViewController:tabBarViewController2 animated:YES];
  [tabBarViewController2 release];

NSLog(@"finished edit tabbar\n");

}

如果您单击moreNavigationController的显示页面上的编辑按钮,你得到的日志条目喜欢预期,(这是奇怪)堆栈攀登的意见 - 但没有发生改变页面。我画下来到没有使用正确的导航控制器...但我失去了对如何找到使用哪一个。

这是一个奇怪的一个太。在编辑功能,如果我只是这样做:

- (void) editTabBar:(id)sender {
self.tabBarController.selectedIndex = 0;
}

它确实需要我家(商tabbarcontroller 0)

但是这样做:

 - (void) editTabBar:(id)sender {
    [self.navigationController popToRootViewControllerAnimated:YES];
    }

不起作用。

是否moreNavigationController有一些特殊的质量与该系统的其余部分的螺钉?

有帮助吗?

解决方案

我会尝试重新实现从无到有整个“更多”功能。换句话说,可以存储4个标签在用户违约,并添加切换到多视图控制器堆栈的自己完全重新实施一个虚拟的第五个标签。

您甚至可以写的UITabBarController的轻量级子类,处理这个给你。

其他提示

UITabBarController是邪恶的,所以我不会在所有如果MoreController有一些特殊的性能感到惊讶了。

我已经成功拦截在shouldSelectViewController改变数据源中的多个控制器;你或许可以找到一些解决办法在那里。

PS我倾向于同意,你可以考虑重新设计的应用程序,让你并不需要连接到标签栏只选择类别viewControllers的数量不受限制;你可以使用一个单一的,滚动的,自其在视图中的工具栏有更好的运气。如果真的选择的类别为您的应用程序,当然是最好的办法。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top