marcc
marcc

Reputation: 12399

Subclass of UITabBarController, replaced the TabBar and have a display issue

I have an iPhone app which was built using a standard UITabBarController. This app was created using the standard XCode project template.

Now, I have a requirement to change the UITabBar to look very different. The approach I decided to take was like this:

in my AppDelegate:

for (UIView *view in tabBarController.view.subviews) {  
    if([view isKindOfClass:[UITabBar class]]) {
        view.hidden = YES;
        break;
    }
}

This works to make the tab bar hidden. Next, I subclassed UITabBarController and I add a UIToolbar with a few custom components. In my subclassed UITabBarController I have my code set up so that when one of my custom objects is selected, the code simply calls [self setSelectedIndex:n] to update the UI.

So I basically have a UITabBarController but I am controlling it through a new UI.

The problem is that my new components aren't quite as tall as the normal UITabBar and the UITabBarController seems to be not resizing my views automatically. I actually would expect this behavior, but I can't figure out how to change the "content frame" of a UITabBarController. Any ideas?

Upvotes: 3

Views: 4446

Answers (2)

marcc
marcc

Reputation: 12399

Resolved with the following code:

[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 436)];

(I know this code has issues btw and will come back to haunt me on the iPad or other devices).

Upvotes: 0

David Sowsy
David Sowsy

Reputation: 1680

  1. Check the autoresizingMask property.
  2. Are you expecting them to work as tab bars usually do by adding items to the viewControllers view?

Upvotes: 1

Related Questions