Question

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!

Was it helpful?

Solution

Just do

self.navigationItem.leftItemsSupplementBackButton = YES;
self.navigationItem.leftBarButtonItems = @[item1, item2];

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top