Hide UINavigation Bar in Push Segue Animation

On February 6, 2014, in iPhone iPad Object-C, by James Liu

Last time, we talk about how to create a Push segue animation without UINavigation controller. The problem I want to solve is that I want to use horizontal sliding effect as ViewController transition without using UINavigation. However, there is no horizontal sliding effect in model segue. Therefore, I have to use custom style segue and define a custom segue. With the custom style segue, we can easily switch ViewControllers without any pain.

In this IOS tutorial, I will show you a new way to apply Push segue by using UINavigationController, but hide the navigation bar. This approach is more clean, nice and easy to understand. It is also very easy for you to use in your own project. Because we are using a normal UINavigator, all view transition are implemented by UINavigationController functions including pushViewController and popViewControllerAnimated.

My working environment is Mac OS X Mavericks with Xcode 5.0.2. Deployment target is 7.0. Target device is iPhone. You can also use this source code in your iPad project.

In this example, I will create 3 UIViewController with xib and a CommonClass which will contains all view reference and UINavigationController reference. First, let’s see the source code of CommonClass.m.

#import "CommonClass.h"

@implementation CommonClass
@synthesize navigationController;

static CommonClass *instance = nil;

+ (CommonClass *) instance {
    if (instance == nil) {
        instance = [[CommonClass alloc] init];
    return instance;

- (FirstViewController *) getFirstView
    if (firstView == nil) {
        firstView = [[FirstViewController alloc] init];
    return firstView;

- (SecondViewController *) getSecondView
    if (secondView == nil) {
        secondView = [[SecondViewController alloc] init];
    return secondView;

- (ThirdViewController *) getThirdView
    if (thirdView == nil) {
        thirdView = [[ThirdViewController alloc] init];
    return thirdView;

- (UINavigationController *) getNavigator:(UIViewController *)viewController
    if (navigationController == nil) {
        navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
    return navigationController;

In AppDelegate.m, I will override for customization after application launch in the application function. Here is the source code of AppDelegate.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    UIViewController *firstView = [[CommonClass instance] getFirstView];
    UINavigationController *navigator = [[CommonClass instance] getNavigator:firstView];
    self.window.rootViewController = navigator;
    [UIApplication sharedApplication].statusBarHidden = YES;
    navigator.navigationBarHidden = YES;
    [self.window makeKeyAndVisible];
    return YES;

After that, let’s see how we can switch views by push segue. I will show one ViewController source code. It will use UINavigationController to show next view by push segue. Here is the source code example.

- (IBAction)gotoNextView:(id)sender
    UIViewController *nextView = [[CommonClass instance] getSecondView];
    UINavigationController *nav = [[CommonClass instance] navigationController];
    [nav pushViewController:nextView animated:YES];

Get Full Source Code under $2.99

Get this example under $2.99. With this source code, you can use the same function in your project, so that you can implement Push Segue and hide UiNavigationController Bar.

In this example source code, it includes:

  • FirstViewController.m, first View viewcontroller class
  • SecondViewController.m, second View viewcontroller class
  • ThirdViewController.m, third View viewcontroller class
  • CommonClass.m, the singleton class which contains all class reference
  • AppDelegate.m, the application entry class
Tagged with:  

4 Responses to “Hide UINavigation Bar in Push Segue Animation”

  1. Daniel says:



  2. Arne Houben says:

    Is it possible to get this code in swift?


Leave a Reply


WordPress Themes