You could write the animation code manually. Here are the general steps:
- Create a subclass of
UIViewController
(essentially a dud controller to house your UITabBarController
) - I usually call this ShellViewController
.
- In the
ShellViewController
's init
method (whichever one you would use), set its frame
outside of the screen to the right, e.g. [self.view setFrame:CGRectMake(320, 0, 320, 480)];
- Create two methods within
ShellViewController
- (void)presentSelf
- (void)dismissSelf
- Create an instance of
ShellViewController
when you want to present your UITabBarController
- Place your
UITabBarController
instance inside of the ShellViewController
instance
- Call
[currentView addSubview:shellViewController.view];
- Use the custom methods above to present and dismiss the
ShellViewController
housing your UITabBarController
- Deal with memory management as your business logic dictates
Here is the code for animating-in (e.g. the - (void)presentSelf
method):
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.15]; //the double represents seconds
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[[self view] setFrame:CGRectMake(0, 0, 320, 480)];
[UIView commitAnimations];
Here is the code for animating-out (e.g. the - (void)dismissSelf
method):
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.15];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[[self view] setFrame:CGRectMake(320, 0, 320, 480)];
[UIView commitAnimations];
Keep in mind that these animation methods do only that: animate. They don't disable interaction with the current view nor with the ShellViewController
's view/subviews which are being animated in/out. You'll need to manually disable user interaction during animation and then reinstate it after the animation is finished. There is a UIView
method that performs a selector when animation is finished:
[UIView setAnimationDidStopSelector:@selector(enableUserInteraction)];
You can put this right after the [UIView setAnimationDelegate:self]
in each animation block above. Of course, you would need to write the enableUserInteraction
method yourself... and disableUserInteraction
method for that matter.
It is a hassle to go this route, but it works. Once you get the ShellViewController
written up, it makes for a nice reusable snippet.