user549767
user549767

Reputation: 437

how to display buttons in tab bar programmaticaly in iphone

Im new to iphone development. here in my application i want to add two buttons in tab bar.

here i displayed barbutton item in view but i dont no how to display buttons in tab bar.

can any one plz help me about my problem. how to display buttons in tab bar programmaticaly in iphone.

thank you in advance.

Upvotes: 0

Views: 129

Answers (1)

Jensen2k
Jensen2k

Reputation: 8408

Check out the UITabBar-documentation: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBar_Class/Reference/Reference.html

You can use

- (void)setItems:(NSArray *)items animated:(BOOL)animated

to set items to your tabbar. This array of items needs to contain UITabBarItems, check out the UITabBarItems-documentation for this: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITabBarItem_Class/Reference/Reference.html

A complete exaple would be:

UITabBarItem *barItem1 = [UITabBarItem alloc]
                         initWithTabBarSystemItem:UITabBarSystemItemRecents 
                                              tag:10];
[mytabbar setItems:[NSArray arrayWithObjects:barItem1, nil] animated:NO];
[barItem1 release];

I just wrote this out of my head now, so check the code in xcode, it may fail.

Good luck :-)

Upvotes: 1

Related Questions