Monday, June 10, 2013

UITabBarController customizableViewControllers example in Objective C (iOS).

UITabBarController customizableViewControllers

The subset of view controllers managed by this tab bar controller that can be customized.

@property(nonatomic, copy) NSArray *customizableViewControllers

Discussion of [UITabBarController customizableViewControllers]
This property controls which items in the tab bar can be rearranged by the user. When the user taps the More item on the tab bar view, a custom interface appears displaying any items that did not fit on the main tab bar. This interface also contains an Edit button that allows the user to rearrange the items. [UITabBarController customizableViewControllers] Only the items whose associated view controllers are in this array can be rearranged from this interface. If the array is empty or the value of this property is nil, the tab bar does not allow any items to be rearranged.

Changing the value of the viewControllers property (either directly or using the setViewControllers:animated: method) also changes the value of this property. When first assigned to the tab bar controller, all view controllers are customizable by default.

UITabBarController customizableViewControllers example.
Set tabBarController.customizableViewControllers to something, the easiest case would be:

tabBarController.customizableViewControllers = tabBarController.viewControllers;
after you set up the viewControllers.

Example of [UITabBarController customizableViewControllers].
#import <UIKit/UIKit.h>

@interface CustomTabBarController : UITabBarController {


#import "CustomTabBarController.h"

@implementation CustomTabBarController

- (void)viewDidLoad
    self.customizableViewControllers = nil;
    [super viewDidLoad];


UITabBarController customizableViewControllers example.
// 'Move view' customization
// MORE tab bar items 'More view'
- (void)applicationDidFinishLaunching:(UIApplication *)application {

  UIViewController  * moreController =
  [[self.tabBarController.moreNavigationController viewControllers] objectAtIndex:0] ;
  UITableView * moreTableView = ( UITableView *)  [moreController view];
  [moreTableView setSeparatorColor:[UIColor redColor]];
  [moreTableView setBackgroundColor:[UIColor yellowColor]];

End of UITabBarController customizableViewControllers example article.