0

I am using a storyboard and developping an iPhone app and using a navigation Controller.

when I implemented it I noticed that it is using the name of the view instead of using the default "back" text , is there a way to force it to use "back" ?

Thanks

user1415780
  • 1,153
  • 5
  • 16
  • 33

3 Answers3

0

From http://osmorphis.blogspot.com/2009/03/trapping-uinavigationbar-back-button.html

The only thing you can change on the standard back button is the text. By default, this is the title of the controller. You can change it with code like this:

[self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"New Title" style:UIBarButtonItemStyleBordered target:nil action:nil]; 

Just replace

initWithTitle:@"New Title"

with

initWithTitle:@"Back"
gtmtg
  • 3,010
  • 2
  • 22
  • 35
0

Try to search before asking questions.

Seems that you can add the following code to the controller calling for a drill down, that is the master in a master-detail.

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];

Credit to iPhoneGuy here: iPhone Dev SDK

erran
  • 1,300
  • 2
  • 15
  • 36
0

When you show up the UINavigationController, presumably in your application's delegate, make the application's delegate also the navigation controller's delegate. Then watch for view controllers being popped and pushed:

AppController.h

#import <UIKit/UIKit.h>

@interface AppController.h : NSObject 
<UIApplicationDelegate, UINavigationControllerDelegate> 
{
    UIWindow *window;
    UINavigationController *viewController;
}
/* MARK: Interface Outlets */
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *viewController;
@end

AppController.h

#import "AppController.h"

@implementation AppController.h
/* MARK: Init and Dealloc */
- (void)dealloc {
    self.window = nil;
    self.viewController = nil;

    [super dealloc];
}

/* MARK: Interface Outlets */
@synthesize window, viewController;

/* MARK: Application Delegate */
- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    assert(self.window != nil);
    assert(self.viewController != nil);

    self.viewController.delegate = self;

    /* other initialization */

    [self.window makeKeyAndVisible];

    return YES;
}

/* MRK: Navigation Controller Delegate */
- (void)navigationController:(UINavigationController *)navigationController 
      willShowViewController:(UIViewController *)vc 
                    animated:(BOOL)animated
{
    UIBarButtonItem *myItem = /* initialize */;

    navigationController.topViewController.navigationItem.backBarButtonItem = nil;
    navigationController.topViewController.navigationItem.backBarButtonItem = myItem;
}
@end

Additionally, you can ignore custom view controllers by checking wether -[NSObject isKindOfClass:] match for the wanted view controllers.

v1Axvw
  • 3,054
  • 3
  • 26
  • 40