UISegmentedControl gone wild ;-)

Discussion in 'iPhone/iPad Programming' started by lawicko, Sep 2, 2008.

  1. macrumors member

    Joined:
    Jul 17, 2008
    Messages:
    44
    #1
    Hi,
    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.
     
  2. macrumors newbie

    Joined:
    Sep 22, 2007
    Messages:
    10
    #2
    Hi,

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

    Hope that helps,
    Rafael
     
  3. macrumors member

    Joined:
    Jul 17, 2008
    Messages:
    44
    #3
    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?
     

Share This Page