Reputation: 437
here in my application i want to add barbuttonitem in tab bar.
i displayed tab bar in view but i dont no how to add barbuttonitem programmaticaly in iphone.
can any one plz give me information about my problem.
thank you in advance..
Upvotes: 1
Views: 3322
Reputation: 5123
You can not add bar button items to tab bar.
To add bar button item to a toolbar
//Create a BarButtonItem configure the way you want.
self.forwardButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay
target:nil action:nil];
// Create an array for all the bar buttons
NSArray *toolBarItems = [[NSArray alloc] initWithObjects:forwardButton,nil];
// Set toolar items
[self.toolBar setItems:toolBarItems];
// add items to toolbar
[self addSubview:self.toolBar];
EDIT
In case you want to add space between BarButtonItems
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:NULL];
Upvotes: 2
Reputation: 10011
You cannot add barbuttonitem in tab bar. You can add barbuttonitem in tool bar. for that check out this link
Upvotes: 0