Reputation: 187
I have placed code in my App Delegate such that I can transition from one view controller to another.
However when I press the button, the transition to my SecondViewController
is not made. How should I go about doing this? any simple way to bring next view controller,(pushview controller)...
Here is my code:
SecondViewController *aSecondView = [[SecondViewController alloc] init];
[self setSecondViewController:aSecondView];
[aSecondView release];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:window
cache:YES];
[viewController.view removeFromSuperview];
[self.window addSubview:[secondViewController view]];
[UIView commitAnimations];
Upvotes: 0
Views: 2347
Reputation: 27601
While you haven't posted more of your code so I can't be certain, there's a code smell coming from doing your controller transitions inside your app delegate. Since you describe a button that initiates the transition, my question is, why aren't you using a navigation controller and/or presenting your second view controller modally, inside the view controller that owns the button?
Modify your app delegate judiciously -- I mostly only use mine for doing one-time, global tasks, such as loading a Core Data store/sqlite database, etc.
Upvotes: 1
Reputation: 39690
Well, since you're not using the built-in functions for presenting view controllers, you will have to call all of the view*Appear:
functions:
I'm not sure if that will fix the problem, though. You may want to instead use presentModalViewController:animated:
to push the new view. If it's not logically a subview of the current view, then have a root view push the first view, then when you want to transition, dismiss the first view and present the second from the (never seen) root view.
Upvotes: 0