View Full Version : UISegmentedControl gone wild ;-)

Sep 2, 2008, 08:57 AM
I have some questions about UISegmentedControl. I want to create control with 2 segments, and I don't want it to be momentary. The result is that no matter which segment I touch, UIControlEventValueChanged is send to my selector. This is really annoying :mad:
I was trying to find out what's going on, and studied two examples:
1. UICatalog has the example of segmented control, but it has 3 segments, not two. When I add another segment to my control, it starts to behave as I want. Unfortunately, for 2 segments the behavior is different from expected. The fact that I have only 2 segments does not mean that whenever I touch I want to change the state...
2. NavigationBar example has nice segmented control, and it behaves almost as I would like mine to behave. The problem is that it's momentary, so the segments don't stay in selected state, they go back to normal.

So if anyone of you guys has good idea how to implement segmented control as described above - please give me some hints. Thanks in advance.

Dec 30, 2008, 09:18 PM

don't know if you have already figured it out, but I use:
- (void)setAlwaysToggleForTwoSegments:NO;

Hope that helps,

Dec 31, 2008, 04:17 AM
Hi, thanks for the reply!
Looks like really simple solution, but where did you get that method from? I don't see it in UISegmentedControl class reference... Is it similar to terminate method of UIApplication class - so it's not documented but it's there?