I want to push viewControllers to an area on my main viewController. From what I understand, you can't use a NavigationController unless you are adding it to a UIWindow.
This animation reminds of UIScrollView horizontal scrolling. But I want it to work like a NavigationController instead. The ViewControllers will be changed when the user presses on specific actions.
ViewController2 is going to be a tableView with some other buttons.
ViewController3 is going to be a form to change the object from the tableView.
I Actually solved it by playing around with UIView Animations.
-(void)slideInView:(UIView*)newView toView:(UIView*)oldView {
/* Sets the view outside the right edge and adds it to mainView */
newView.bounds = mainView.bounds;
newView.frame = CGRectMake(newView.frame.origin.x + 784, newView.frame.origin.y, newView.frame.size.width, newView.frame.size.height);
[mainView addSubview:newView];
/* Begin transition */
[UIView beginAnimations:@"Slide Left" context:oldView];
[UIView setAnimationDelegate:self];
[UIView setAnimationDelay:0.0f];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationDidStopSelector:@selector(slideInCompleted:finished:context:)];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
newView.frame = CGRectMake(0,0, newView.frame.size.width, newView.frame.size.height);
oldView.frame = CGRectMake(oldView.frame.origin.x - 784, oldView.frame.origin.y, oldView.frame.size.width, oldView.frame.size.height);
[UIView commitAnimations];
}
-(void)slideInCompleted:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
UIView *view = (UIView*)context;
[view removeFromSuperview];
}
and to use it
menuController = [[MenuViewController alloc] init];
[self slideOutView:menuController.view toView:loginController.view];
[oldController release];
Remeber that you have alloced a UIViewController that you need to release when you are done useing it! In example i'm done with loginController and releasing it.