user549767
user549767

Reputation: 437

how to add barbutton item in tab bar programmaticaly in iphone

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

Answers (2)

k-thorat
k-thorat

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

Robin
Robin

Reputation: 10011

You cannot add barbuttonitem in tab bar. You can add barbuttonitem in tool bar. for that check out this link

http://www.iphonedevsdk.com/forum/iphone-sdk-development/59285-programmatically-add-button-uitoolbar.html

Upvotes: 0

Related Questions