Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you add buttons to navigation bars through storyboard?

Tags:

ios

At the moment, I've been adding navigation buttons like follows:

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Add"                                                                           style:self.editButtonItem.style                                                                           target:self                                                                          action:@selector(doneButtonPressed)]; 

It seems a bit silly to not add them through storyboard, but I can't find a way to do so. Is there one that I'm missing?

like image 849
sapi Avatar asked Feb 14 '12 07:02

sapi


People also ask

How do I add a button to the navigation bar?

Use a container element (like <div>) to create the dropdown menu and add the dropdown links inside it. Wrap a <div> element around the button and the <div> to position the dropdown menu correctly with CSS.

How do I add back button to navigation bar storyboard?

Storyboard. You can also set this in the Storyboard. Select UINavigationBar and select the Attributes Inspector tab. Then you can change those two images under Back and Back Mask attributes.

How do I add a navigation bar button in Swift?

You need to open the storyboard, delete the view controller that you have, press cmd , shift , l , and then search for navigation controller . Drag that onto the storyboard. You now need to click on the navigation controller and set it to be the is initial view controller under the attributes inspector .


2 Answers

You can just drag out a Bar Button Item and drop it on the right end of the view controller's navigation bar:

enter image description here

like image 137
rob mayoff Avatar answered Sep 28 '22 02:09

rob mayoff


As of Xcode 6, it looks like the navigation item on the navigation bar is no longer created automatically.

You'll need to drag out a Navigation Item onto the navigation bar first before you can drag out a Bar Button Item (as detailed in Rob's answer) to add to the navigation item.

like image 44
Ken Toh Avatar answered Sep 28 '22 02:09

Ken Toh