UISegmentedControl parts collapse to 0 width
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.
Have you tried setting the explicit component widths or adjusting the control's autoresizing property:
UISegmentedControl not expanding size for navigation bar/very squished
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)
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.
精彩评论