Oliver
Oliver

Reputation: 23510

iPhone - Creating a simple UINavigationBar with a Back button using Interface Builder

No complex things here. I've added in my xib a navigationBar, and I'd like to add a "back" button on its left. But nothing works. I've added "many" other buttons, but I can't achieve adding this one...

Do you know how I may do ?

Upvotes: 1

Views: 3025

Answers (1)

WrightsCS
WrightsCS

Reputation: 50707

You can either add text or a small image for the back button.

In the viewDidLoad scope, add:

/*  add an image  */
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init];
[backButton setImage:[UIImage imageNamed:@"back.png"]];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];

/*  add text  */
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init];
[backButton setText:@"Back"];;
self.navigationItem.backBarButtonItem = backButton;
[backButton release];

Upvotes: 2

Related Questions