Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a button next to the back button

in iOS, is it possible to add a button next to the default back button (the one that is automatically created when you use the method pushViewController)

I would like to add a button here !

I've tried to use the methods setLeftBarButtonItems and setBackBarButtonItem but in vain - whenever I set the left bar button items, the default back button disappears.

Thanks for your help!

like image 980
Arnaud Avatar asked Sep 12 '13 09:09

Arnaud


People also ask

How do I customize the back button on my iPhone?

Turn on Back Tap Check that you have the latest version of iOS on your iPhone 8 or later. Go to Settings > Accessibility > Touch, and tap Back Tap. Tap Double Tap or Triple Tap and choose an action. Double or triple tap on the back of your iPhone to trigger the action you set.

How do you make a Continue button in HTML?

HTML <button> Tag.

How do I add a back arrow in HTML?

You can use the history. back() method to tell the browser to go back to the user's previous page. One way to use this JavaScript is to add it to the onclick event attribute of a button. Here, we create the button using a <form> element, containing an <input> element of the button type.


2 Answers

Just do

self.navigationItem.leftItemsSupplementBackButton = YES;
self.navigationItem.leftBarButtonItems = @[item1, item2];
like image 112
Thomas Keuleers Avatar answered Oct 04 '22 19:10

Thomas Keuleers


I haven't tested the following code, but it should work as long as the backBarButtonItem has been initialised.

[[self navigationItem] setLeftBarButtonItems:[NSArray arrayWithObjects:[[self navigationItem] backBarButtonItem], [[UIBarButtonItem alloc] initWithTitle:@"Custom" style:UIBarButtonItemStylePlain target:self action:@selector(action:)], nil]];\

Essentially, you're setting the entire left bar button item array from scratch but providing the back button along with your own custom button.

like image 22
Zack Brown Avatar answered Oct 04 '22 19:10

Zack Brown