When to use addChildViewController vs pushViewController

Yes, pushViewController: is for navigation controllers that manage a stack of view controllers. addChildViewController: on the other hand is part of an iOS 5 feature called “view controller containment”. The basic idea behind this is that you can embed your view controllers into other view controllers of your own (e.g. when porting an iPhone app … Read more

Showing pushviewcontroller animation look like presentModalViewController

If you want to a fade animation, this approach works. CATransition* transition = [CATransition animation]; transition.duration = 0.3; transition.type = kCATransitionFade; transition.subtype = kCATransitionFromTop; [self.navigationController.view.layer addAnimation:transition forKey:kCATransition]; [self.navigationController pushViewController:gridController animated:NO];

Restore pre-iOS7 UINavigationController pushViewController animation

I managed to workaround the new transition type by creating a category for UINavigationController. In my case I needed to revert it to the old transition style because I have transparent viewControllers that slide over a static background. UINavigationController+Retro.h @interface UINavigationController (Retro) – (void)pushViewControllerRetro:(UIViewController *)viewController; – (void)popViewControllerRetro; @end UINavigationController+Retro.m #import “UINavigationController+Retro.h” @implementation UINavigationController (Retro) – … Read more

How can I go back to the initial view controller in Swift?

SWIFT: You should use an unwind segue. First of all, put the following line in your FirstViewController: @IBAction func prepareForUnwind(segue: UIStoryboardSegue) { } The function actually doesn’t have any code inside it. Now, go to your storyboard and create an unwind segue for LogoutViewController by control-dragging from the yellow button to the Exit button. Like … Read more

popping and pushing view controllers in same action

MapsViewController *aViewController = [[MapsViewController alloc] initWithNibName:@”MapsViewController” bundle:nil]; // locally store the navigation controller since // self.navigationController will be nil once we are popped UINavigationController *navController = self.navigationController; // retain ourselves so that the controller will still exist once it’s popped off [[self retain] autorelease]; // Pop this controller and replace with another [navController popViewControllerAnimated:NO];//not to … Read more

Completion handler for UINavigationController “pushViewController:animated”?

See par’s answer for another and more up to date solution UINavigationController animations are run with CoreAnimation, so it would make sense to encapsulate the code within CATransaction and thus set a completion block. Swift: For swift I suggest creating an extension as such extension UINavigationController { public func pushViewController(viewController: UIViewController, animated: Bool, completion: @escaping … Read more