Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a UISegmentedControl return to its action on UIControlEventValueChanged?

So, I have a UISegmentedControl with:

[control addTarget:self action:@selector(myAction) forControlEvents:UIControlEventValueChanged];

Just wondering how I would find out what segment has been selected (so I can do the appropriate action). I know its something like:

@selector(myAction:) but what gets sent? ie: when I define my method what do I have to define?

Thank you.

like image 636
Thomas Clayson Avatar asked Aug 23 '10 15:08

Thomas Clayson


1 Answers

get the selected item... second part of question

-(IBAction) myAction:(id)sender{
    NSLog(@"myAction",nil);

    UISegmentedControl * control = sender;
    int selectedIndex = [control selectedSegmentIndex];
}
like image 133
Aaron Saunders Avatar answered Oct 17 '22 00:10

Aaron Saunders