views:

223

answers:

3

Bug

Anyone had a smiliar bug? The control is placed from Interface Builder and not modified in any way by code. It was working fine until some time ago after a random build the bug appeared. Happens in two places in my app while the same exact kind of setup is fine inside another viewcontroller. In all cases the controls are inside a UINavigationItem. Deleting the control and re adding it didn't change anything. This only appreas on an actual device, never in the simulator.

A: 

Have you tried setting the explicit component widths or adjusting the control's autoresizing property:

http://stackoverflow.com/questions/2936450/uisegmentedcontrol-not-expanding-size-for-navigation-bar-very-squished

Chris Gummer
Yes and no. Setting the autoresizing property fixes the bug, but only when the view controller doesn't get pushed onto the screen via a uitabbarcontrollers moreviewcontroller. Ie, if I set the selected index on my main tabbar to 5, it displays fine, but if I navigate there through the more menu, it's no dice.
Joonas Trussmann
Do you have a sample app that demonstrates this behaviour, that you can share?
Chris Gummer
I'm afraid I don't at the moment, but I'll try to see if I can replicate this with a new app.
Joonas Trussmann
A: 

Have you tried creating it programatically? It definitely seems to be a bug, but this approach might negate the bugs.

Declare an IBOutlet for the UINavigationItem:

IBOutlet UINavigationItem *navItem;

then when it loads do:

segCont=[[UISegmented Control alloc] initWithItems:[NSArray arrayWithObjects:@"item 1", @"item 2", nil]];

segCont.segmentedControlStyle=UISegmentedControlStyleBar;  //Optional, but in a toolbar it looks best

navItem.titleView=segCont;

[segCont autorelease];

I have not tested this code, but if it doesn't work please comment... (It may still be under the influence of the bug, however)

Tom H
That kind of defeats the purpose of having my view hierarchy loaded from nibs, but I'll give it a try nonetheless.
Joonas Trussmann
A: 

Since none of the solutions proposed actually fixed the issue properly I guess the only solution seems to be to just upgrade to the 4.0 SDK, which seems to fix the issue.

Joonas Trussmann