简体   繁体   中英

add bar button item next to back button on navigational bar

I have dragged+dropped Navigational bar from storyboard and a bar button item is placed at the left extreme .

I would like to add another button next to it but I am unable to do it ,its only excepting on the right extreme.I dont want that .

Its on iPad so there is lots of space on the navigational bar.How Do I implement this ?

I tried creating a bar button item but that covers the navigation bar and that not what I exactly want .

I want hide the 1 button of toolbar if possible so that back button of navigational bar can be seen .

Please suggest me something on how to get a Bar Button Item next Left extreme button on a Navigational Bar ? Thanks in Advance.

If you're planning on using your own custom back button, and are willing to link the back action manually, (which I'm guessing you are because you added a nav bar in IB, not from the nav controller) you can use a UIToolBar instead.

Tool bars support multiple buttons, and allow you to more precisely arrange them using fixed and flexible space UIBarButtonItems.

在此输入图像描述

To do this to a navigation bar added by your navigation controller, you have to add the buttons programmatically:

UIBarButtonItem *myItem1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(someMethod)];
UIBarButtonItem *myItem2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(someMethod)];

[[self navigationItem] setLeftBarButtonItems:[NSArray arrayWithObjects:myItem1,myItem2, nil]];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM