好的,这是我的问题:我的应用程序在 iPhoneOS 屏幕底部的标签栏中显示了类别。在出现更多按钮之前,这只允许 5 个类别。我有超过 25 个(请不要回答这个问题:“重新考虑你的应用程序......等等”——这是之前粗鲁地说的。它们是食物、饮料等类别,不能更改)。我想让用户将他们的收藏夹放在主页上。苹果的moreNavigationController编辑系统由于编辑页面的空间限制,只允许重新排列20个标签栏项。这还不够,所以我需要实现我自己的编辑屏幕。我将 rightBarButtonItem 设置为 nil 并创建了我自己的。使用 NSLog,我可以看到单击 EDIT 按钮时发生“单击”,但我无法使用 pushViewController 推送。没发生什么事。我认为这与我正在处理的导航控制器有关......但我不确定。ps:这一切都发生在我的 App Delegate 中,它同时充当 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];
}
}
这可以在屏幕右上角放置一个 EDIT 按钮——模仿 Apple 的外观和感觉……但是当单击该按钮时,您无法退出该死的 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 是否有一些特殊的品质可以与系统的其余部分结合使用?