开发者

Is it possible in a UITabBarController to have one tab in a fixed position and able reorder the other tabs?

I would lik开发者_运维问答e for one tab in a UITabBarController to have a fixed position and the user can reorganize the other tabs however they like. I have the UITabBarController > UINavigationController > UITableViewController setup.

Is this possible?

UPDATE:

The following code, in applicationDidFinishLaunching, is what I'm using and it doesn't work. I'm trying to get a reference to the SavedTableViewController, I think that's the problem. Any ideas?

NSMutableArray *customizableVCs = [NSMutableArray arrayWithArray:tabBarController.customizableViewControllers];
    for (id controller in tabBarController.customizableViewControllers){
            if ([controller isKindOfClass:[SavedTableViewController class]]){
                NSLog(@"Removing Object");
                [customizableVCs removeObject:controller];
            }
    }
    tabBarController.customizableViewControllers = customizableVCs;

UPDATE 2:

This is the code that worked for me. I had to put the snippet below adding the tabBarController to the window.

[window addSubview:tabBarController.view];
    [self setTabOrderIfSaved];

    NSMutableArray *customizableViewControllers = [NSMutableArray arrayWithArray:tabBarController.customizableViewControllers];
    [customizableViewControllers removeObject:savedNavigationController];
    tabBarController.customizableViewControllers = customizableViewControllers;


Remove the view controller corresponding to that tab from the customizableViewControllers property of your tab bar controller. Assuming that you want fixedViewController to remain fixed:

NSMutableArray *customizableViewControllers = [NSMutableArray arrayWithArray:tabBarController.customizableViewControllers];
[customizableViewControllers removeObject:fixedViewController];
tabBarController.customizableViewControllers = customizableViewControllers;

Because customizableViewControllers is reinitialized when the viewControllers property is changed, you should do this after the rest of your tab bar controller’s state has been set up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜