0
UITabBar *frameTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 698, 1024, 70)];
UITabBarItem *frameTabBarItem1 = [[UITabBarItem alloc] initWithTitle:@"Fee" image:nil tag:0];
UITabBarItem *frameTabBarItem2 = [[UITabBarItem alloc] initWithTitle:@"Dev" image:nil tag:1];
NSArray *frameTabBarItemArray = [[NSArray alloc] initWithObjects:frameTabBarItem1,frameTabBarItem2,nil];
[frameTabBar setItems:frameTabBarItemArray];

But there isnt any Item displayed in my UITabBar. What's wrong with my code. Thanks.

3 Answers 3

1

I'm sure that the items are there, you just can't see them because you didn't set an image and the labels are out of your visible frame.

UITabBar *frameTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 698, 1024, 70)];

698 + 70 = 768

768 is the height of an iPad in landscape orientation. But, if there is a statusbar, the usable frame is 20 pixel smaller. And the 20 pixel are exactly the height that would hide your tab labels.

So just subtract 20 pixel from the y position and you are good.

UITabBar *frameTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 678, 1024, 70)];
0

I believe that the problem is that You should implement the tabBarDelegate in your header file and set your ViewController as the delegate?

in your .h file:

@interface MyViewController : UIViewController <UITabBarDelegate> 

in your .m file:

frameTabBar.delegate=self;

Hope it will help

1
  • Thanks for you reply, but i think it isn't delegate issue.
    – Jerry
    Feb 14, 2011 at 7:49
0

try it m sure it will work......

[self.view addSubview:frameTabBar];

Thanks Pankaj Chauhan

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.