I have a navigation bar with a left and right button, and I need to put another button next to the right button. Does anyone know how I can go about this? Here is some code to help:
- (id)init { self = [super initWithStyle:UITableViewStyleGrouped]; if (self) { _pinArray = [[NSArray alloc]init]; _pinArray = [Data singleton].annotations; UIBarButtonItem *right = [[UIBarButtonItem alloc]initWithTitle:@"Map" style:UIBarButtonItemStylePlain target:self action:@selector(goToMap:)]; self.navigationItem.rightBarButtonItem = right; UIBarButtonItem *left = [[UIBarButtonItem alloc]initWithTitle:@"Menu" style:UIBarButtonItemStylePlain target:self action:@selector(goToMenu:)]; self.navigationItem.leftBarButtonItem = left; self.navigationItem.title = @"My Homes"; } return self; }
From Settings, tap Display, and then tap Navigation bar. Make sure Buttons is selected, and then you can choose your desired button setup at the bottom of the screen.
You can use the navigation buttons to move through menus. There are four navigational buttons that you can use to move throughout a menu: up, down, right, and left. Each button corresponds to the direction that you can move in a menu.
It's quite easy :)
https://developer.apple.com/documentation/uikit/uinavigationitem/1624956-rightbarbuttonitems
navigationItem.rightBarButtonItems = [rightA, rightB] // @[rightA, rightB] for ObjC
Instead of using self.navigationItem.rightBarButtonItem
, use
self.navigationItem.rightBarButtonItems //note the plural
This allows you to set an array of buttons rather than a single one.
See the UINavigationItem class reference for details.
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