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'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!
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.
HTML <button> Tag.
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.
Just do
self.navigationItem.leftItemsSupplementBackButton = YES;
self.navigationItem.leftBarButtonItems = @[item1, item2];
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With