0

Weird question but I'm using a navigation bar on my UIViewController and I was trying to add a normal UIButton to the left side of the navigation bar so I could add code to it as well as make it disappear, but now I've dragged it up there I can't get move/delete it or anything like that.

Other than setting it's text to nil programmatically, do I have any other options?

Cheers; also is there a way to add code to the normal backBarButtonItem??

Thanks guys

edit: I've added all the buttons using the storyboard Xcode 5 enter image description here

Grey_Code
  • 454
  • 1
  • 4
  • 20
Javanoob33
  • 89
  • 3
  • 12
  • Can you add some code, hw u add the button? – pankaj asudani Apr 18 '14 at 11:37
  • I add it using the storyboard. – Javanoob33 Apr 18 '14 at 11:39
  • http://stackoverflow.com/questions/2848055/add-button-to-navigationbar-programatically this will help you. – Dileep Apr 18 '14 at 11:42
  • In your picture right under the T in Table View Controller and a bit to the left is a square with an arrow. Click that and it will bring out the out line for your story boards. Click on and expand your Edit Favourite view controller and a list of everything will be shown. Click on the nag bar and it should show you all the subview of it. Click on the button you want to delete and press delete. – Douglas Apr 18 '14 at 11:53
  • you are a legend Douglas thank you so much. Post that as an answer so I can accept it and vote up haha. Thanks heaps – Javanoob33 Apr 18 '14 at 11:56

3 Answers3

0

In your picture right under the T in Table View Controller and a bit to the left is a square with an arrow. Click that and it will bring out the out line for your story boards. Click on and expand your Edit Favourite view controller and a list of everything will be shown. Click on the nav bar and it should show you all the subview of it. Click on the button you want to delete and press delete.

Douglas
  • 2,524
  • 3
  • 29
  • 44
-1

You can try this code:

UIBarButtonItem *barBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(pop)];
self.navigationItem.backBarButtonItem = barBtnItem;
[barBtnItem release];
pankaj asudani
  • 862
  • 6
  • 18
  • okay cool thanks, so how would I use that as a normal button then? i.e. Link it up from the storyboard as an outlet so I can add a method to it? / remove the other ones?? Thanks – Javanoob33 Apr 18 '14 at 11:40
  • You can refer this link: http://stackoverflow.com/questions/9273204/can-you-add-buttons-to-navigation-bars-through-storyboard – pankaj asudani Apr 18 '14 at 11:41
  • Thanks for the link, but I need to be able to add it on the left side, where the back button is but I can't delete them. – Javanoob33 Apr 18 '14 at 11:42
  • simply click the button and press delete button on keyboard. – pankaj asudani Apr 18 '14 at 11:43
  • I've tried that, but it doesn't allow me to delete them. – Javanoob33 Apr 18 '14 at 11:44
  • You can use self.navigationItem.hidesBackButton = YES; in ViewDidLoad() method to hide the back button in UINavigationController. – user2071152 Apr 18 '14 at 11:47
  • why u want to delete, u can change the text as your customization. – pankaj asudani Apr 18 '14 at 11:47
  • Because I have two buttons literally right next to eachother and I need to delete one of them. Thanks user, I added that but now it just hides the entire navigation bar for some reason? – Javanoob33 Apr 18 '14 at 11:48
  • For adding the Custom back button you can use self.navigationItem.leftBarButtonItem = backBarButtonItem; before that you can create UIButton component and add it to UIBarButtonItem. – user2071152 Apr 18 '14 at 11:52
-1

If you dont want your buttons to go behind navigation bar then you should deselect Extend Egdes to Top and Bottom bars. You can do it by selecting view controller and at setting you will see:

Extending Edges

If you want to change the leftBarButton you should follow iDeveloper's Guide

UIBarButtonItem *barBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(pop)]; self.navigationItem.leftBarButton= barBtnItem;

E-Riddie
  • 14,660
  • 7
  • 52
  • 74
  • No, this is a terrible suggestion. I am tired of seeing these lazy solutions. If he doesn't want views to go under the navigation bar, he should set up his views correctly, rather than disable functionality. – Léo Natan Apr 18 '14 at 21:51
  • He said that he wants to delete that button, so if wants to delete it, he can deselect them, remove button and bring them back if he wants! I was refering to the question, and I gave a way that he might wants to do! – E-Riddie Apr 18 '14 at 21:54