0

I'm a total newbie in ios, so judge my question by that.

I have a code to use. In the code i have a vertical tabbar controller inherited from FSVerticalTabBarController. We use this tabbar controller to switch between viewcontrollers.

What i want is to have the viewcontrollers come up with an animation. Any kind of default animation is fine. How can i do that? here's the code, and thank you for your help:

    @implementation AIVerticalTabBarController

@synthesize appDelegate;

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self setDelegate:self];

    [[self tabBar] setBackgroundColor:[UIColor darkGrayColor]];

    NSArray *titles = [NSArray arrayWithObjects:@"Home", @"Export", @"Settings", @"Titles", @"Slides", @"Text doc", nil];
    NSArray *viewClasses = [NSArray arrayWithObjects:@"AIViewController", @"AIViewController", @"AIViewController", @"AITitlesViewController", @"AISlidesViewController", @"AIViewController", nil];

    NSMutableArray *controllersToAdd = [[NSMutableArray alloc] init];
    for (NSUInteger i = 0; i < [titles count]; i++) {
        AIViewController *viewC = [[NSClassFromString([viewClasses objectAtIndex:i]) alloc] init];
        [viewC setAppDelegate:appDelegate];
        UITabBarItem *tbi = [[UITabBarItem alloc] initWithTitle:[titles objectAtIndex:i] image:nil tag:i];



        [viewC setTabBarItem:tbi];



        [controllersToAdd addObject:viewC];
    }

    [self setViewControllers:[NSArray arrayWithArray:controllersToAdd] animated:YES];




}
@end
Filburt
  • 16,221
  • 12
  • 59
  • 107
Zoltan Varadi
  • 2,458
  • 2
  • 31
  • 50

1 Answers1

0

you can do it by adding this method to your appDelegate dont forget to import the QuartzCore lib

-(BOOL)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{

CATransition *transition = [CATransition animation];
transition.duration = 1.0;
transition.type = kCATransitionPush; //choose your animation
[viewController.view.layer addAnimation:transition forKey:nil];
[self.tabBarController.view addSubview:viewController.view];

return YES;   

}

touti
  • 1,137
  • 6
  • 17