views:

745

answers:

2

In my app I have BaseViewController (NavigationController) as the root controller. I normally use the following code to navigate:

[self.navigationController pushViewController:childController animated:YES];

But on one of the actions I want the next view to animate buttom to top, so I use:

[self presentModalViewController:childController animated:YES];

Everything works so far. In the modal view I then want to push another controller, but this doesn't seem to work. I have tried the following:

// self.navigationController is null, so this doesn't work
[self.navigationController pushViewController:childController animated:YES];

// self.parentViewController is the BaseViewController and not null, but this 
// won't work either. This also generates a warning "UIViewController' may not 
// respond to '-pushViewController:animated:"
[self.parentViewController pushViewController:childController animated:YES];

In both cases nothing happens. Is pushViewController disabled while a modal view is still showing? If so, is there another way I can:

  1. Animate next controller from bottom to top
  2. Animate the next controller from left to right, with a back button as usual. The back button should take you back to the previous (modal) view.

?

+1  A: 

If you presentModelViewController then you need to dismiss it before you can call the navigation controller's methods, otherwise you have to put this view controller into the navigation stack in order to put another view controller on top of it.

sfa
Based on your answer, I made a solution that works. Instead of presenting the childcontroller modal directly, I create another instance of BaseViewController and add this one modally. The pushViewController then works as expected, since the modal view now contains a navigationcontroller:ChildController *childController = [[ChildController alloc] init];BaseTrackingViewController *baseController = [[BaseTrackingViewController alloc] initWithRootViewController:childController];[self presentModalViewController:baseController animated:YES];
Mads Mobæk
A: 

This might be helpful: http://stackoverflow.com/questions/574680/core-animation-sheet-like-window-sliding

If you use that in conjunction with [self.navigationController pushViewController:childController animated:NO]; to disable the native animation, it may produce the effect you're looking for.

Don't forget to reverse the operation when popping childController off the nav stack.

Kirk van Gorkom