UISegmentedControl in titleView

5 views
Skip to first unread message

DavidK

unread,
Jun 5, 2009, 5:40:16 PM6/5/09
to RTFM: Development for Mobile Devices
UISegmentedControls with only two segments will toggle when you press
any portion of the control in the 2.X OS. This is supposedly changing
in 3.0, but for now, here is the work around:

@property(nonatomic, assign) BOOL toggleWhenTwoSegments;
@end

@implementation UISegmentedControl(ToggleControl)
@dynamic toggleWhenTwoSegments;
- (BOOL) toggleWhenTwoSegments {
return ( _segmentedControlFlags.dontAlwaysToggleForTwoSegments ==
0 );
}

- (void) setToggleWhenTwoSegments: (BOOL) flag {
_segmentedControlFlags.dontAlwaysToggleForTwoSegments = !flag;
}
@end

You can put this above the @implementation in whatever file needs it
and then call [mySegmentedControl setToggleWhenTwoSegments:NO];

P.S. Jeff, where is that custom cell height code?
Reply all
Reply to author
Forward
0 new messages