Domanda

I am creating a simple app and would like multiple buttons on top bar. I've added one button which would add new items but I want other buttons there as well for the user to go to different screens. This is how it looks now.

enter image description here

Is there a way to add other buttons on the bar? If so, how? Or is it common to have a tab bar for this functionality? Such as this

enter image description here

È stato utile?

Soluzione

Yes, you can have multiple buttons on your navigation bar. You can either add them on the right side or left side of your bar. To do that, you need to create multiple bar buttons and add them as an array. Something like this:

UIBarButtonItem *actionBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:nil];

UIBarButtonItem *addBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];

UIBarButtonItem *bookmarksBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:nil];

self.navigationItem.rightBarButtonItems = @[actionBtn, addBtn, bookmarksBtn]; //Considering that you want to have three buttons on the right side. 

Altri suggerimenti

you can put two buttons on navigation bar one in left and other in right

see screen shot i have done

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top