Search code examples
iosobjective-cuiviewcontrolleruinavigationcontrollerback-button

Objective c - how to display a shorter name of viewController on back button


I almost sure I saw someday that there is some property to set a shorter name of viewController to be display in the back button when it push another viewController and become the back viewController. Can some one remind me what is this property?


Solution

  • - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
        {
        if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
            // Custom initialization
        self.title = @"First View Controller";
    
        // this defines the back button leading BACK TO THIS controller
        UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc]
          initWithTitle:@"Back"
          style:UIBarButtonItemStyleBordered
          target:nil
          action:nil];
        self.navigationItem.backBarButtonItem = backBarButtonItem;
        [backBarButtonItem release];
        }
        return self;
    }