You can write the animation code manually. Here are the basic steps:
- Create a subclass of
UIViewController (basically a dud controller to host your UITabBarController ). I usually call this a ShellViewController . - In the
ShellViewController init method (depending on which one you use) set its frame off-screen to the right, for example. [self.view setFrame:CGRectMake(320, 0, 320, 480)]; - Create two methods in
ShellViewController- (void)presentSelf- (void)dismissSelf
- Create an instance of
ShellViewController if you want to present your UITabBarController - Place an instance of
UITabBarController inside an instance of ShellViewController - Call
[currentView addSubview:shellViewController.view]; - Use the methods above to submit and release the
ShellViewController enclosure of your UITabBarController - A deal with memory management as your business logic dictates
Here is the code for the animation (for example, the method - (void)presentSelf ):
[UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.15];
Here is the code for the animation (for example, the method - (void)dismissSelf ):
[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 the following: aimate. They do not disable interaction with the current view, as well as with ShellViewController view / subviews, which are animated to / from. You will need to manually disable user interaction during the animation, and then restore it after the animation finishes. There is a UIView method that executes the selector when the animation is complete:
[UIView setAnimationDidStopSelector:@selector(enableUserInteraction)]
You can put this right after [UIView setAnimationDelegate:self] in each animation block above. Of course, you need to write the enableUserInteraction method yourself ... and disableUserInteraction , if that is true.
It is not easy to go this route, but it works. After you ShellViewController , it will make a good reusable snippet.
source share