user2420837
user2420837

Reputation: 315

Navigation Bar buttons not appearing

I want to add buttons to my navigation bar through code, but they are not appearing for me. I think it might have to do with my navigation bar being inside a UIView.

My code in viewDidLoad:

[super viewDidLoad];

 self.navigationItem.leftBarButtonItem = self.editButtonItem;

 UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add)];
 self.navigationItem.rightBarButtonItem = addButton;

Interface builder:

Interface builder

Any help would be greatly appreciated!

Upvotes: 1

Views: 88

Answers (1)

Léo Natan
Léo Natan

Reputation: 57060

You shouldn't add a navigation bar directly in your view hierarchy. Rather, add a navigation controller, have your view controller as the root controller of the navigation controller, and set the navigation controller as the initial controller of the storyboard (or as the destination controller of segues, etc.).

Upvotes: 1

Related Questions