-1

I am implementing a UIViewController with ScrollView. In the centre of the view I have a ToolBar like that one in the picture:

I have four UIViewControllers to add, one for each button of the toolBar. I do not know if I should init all off them at the beginning and then with a NSArray of viewControllers and one NSArray of booleans manage all of them with this methods:

How could I manage this?? Change viewControllers at the bottom of the toolBar while any button is pressed

- (void) displayContentController: (UIViewController*) content;
{
    scrollView.contentSize =CGSizeMake(scrollView.frame.size.width, self.view.frame.size.height + content.view.frame.size.height );
    [self addChildViewController:content];
    content.view.frame = [self frameForContentController];
    [scrollView addSubview:content.view];
    [content didMoveToParentViewController:self];          
}

- (void) hideContentController: (UIViewController*) content
{
    [content willMoveToParentViewController:nil];  // 1
    [content.view removeFromSuperview];            // 2
    [content removeFromParentViewController];      // 3
}

I have never used childViewControllers actually and I really do not know how to use them

ToolBar View

croigsalvador
  • 1,993
  • 2
  • 24
  • 47

1 Answers1

0

You want to essentially create your own TabBarcontroller. You should use child view controller otherwise auto rotation will not work as expected. You should use an array of ViewControllers (required to pass data) and delegates when your interact with your tabBar. Here is an excellent example which does the same.MHTabBarController.

Here is a sample interface for it:

@interface MHTabBarController : UIViewController

@property (nonatomic, copy) NSArray *viewControllers;
@property (nonatomic, weak) UIViewController *selectedViewController;
@property (nonatomic, assign) NSUInteger selectedIndex;
@property (nonatomic, weak) id  delegate;

- (void)setSelectedIndex:(NSUInteger)index animated:(BOOL)animated;
- (void)setSelectedViewController:(UIViewController *)viewController animated:(BOOL)animated;

@end
Kunal Balani
  • 4,739
  • 4
  • 36
  • 73