Hi All.
I am trying to deal with the fact that when editing the tab view controller customisable list of Navigation controllers, you can only display around 20 on the screen as the view does not scroll.
In order to achieve this I have limited the displayed controllers to the current four in the tabbar, and twelve more, with pageination effectively allowing the rest to be displayed via a next and back button.
This works (sort of)... will post code below. What I cannot get to work is having the edit page unload. I need to do this so that it refreshes with the new list of controllers. At the moment, I push the next button and can get the list to come up by pressing the done and then the edit button again, and I would just like to automate that process. Any thoughts would be great, or if you have found another way to address the limit of 20 (or so) navigation controllers that can be displayed and manipulated via the edit function of the tabbarcontroller.
(PS. I have at times upwards of 30 controllers to display.)
Code.
Note that the application delegate is also the tabBarController delegate as well. tabCtrl is the tabBarController.
- (void)tabBarController

UITabBarController *)tabBarController willBeginCustomizingViewControllers

NSArray *)viewControllers
{
if([tabCtrl.viewControllers count] > 16)
{
UIView *edit_views = [tabBarController.view.subviews objectAtIndex:1];
UINavigationBar *edit_modal_navbar = [[edit_views subviews] objectAtIndex:0];
if(pageIndex == 0)
{
edit_modal_navbar.topItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(nextList)];
}
else if(pageIndex == 1)
{
edit_modal_navbar.topItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backList)];
}
}
}
- (void)nextList
{
NSMutableArray *newViewControllers = [[NSMutableArray alloc] init];
for(int i = 0; i < [tabCtrl.viewControllers count]; i++)
{
if(i < 4 || i > 15)
{
[newViewControllers addObject:[tabCtrl.viewControllers objectAtIndex:i]];
}
}
pageIndex = 1;
[tabCtrl.moreNavigationController popToRootViewControllerAnimated:YES];
tabCtrl.customizableViewControllers = newViewControllers;
[newViewControllers release];
}
- (void)backList
{
NSMutableArray *newViewControllers = [[NSMutableArray alloc] init];
for(int i = 0; i < [tabCtrl.viewControllers count]; i++)
{
if(i < 16)
{
[newViewControllers addObject:[tabCtrl.viewControllers objectAtIndex:i]];
}
}
pageIndex = 0;
[tabCtrl.moreNavigationController popToRootViewControllerAnimated:YES];
tabCtrl.customizableViewControllers = newViewControllers;
[newViewControllers release];
}
Note the two calls to [tabCtrl.moreNavigationController popToRootViewControllerAnimated:YES] do not seem to do anything, which is contrary to what apple indicate a NavigationController should do.
Again any thoughts would be great as I have seen a couple of other posts of people trying to deal with the 20 controller limit, but with no suitable replies.
Cheers.