Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISegmented Contol set to Momentary Handler

This is probably a really simple question but I can't seem to find anything in the APIs or across any search engine.

I have a Segmented control that i have set to momentary as a user will select a couple of makes of a car that they want to search for. The issue that I'm running into is that I can't seem to figure out how to recognize which segment was selected. In regular mode its a simple SelectedSegment = index but with momentary its my understanding that the selected segment is always -1 as none are ever "selected"

I have a handler for ValueChanged but I can't figure out what I'm checking for or what I should be sending to determine which segment was selected. Any help would be greatly appreciated. I'm using monotouch but Obj-C would be fine as well.

Thanks!

like image 940
Adam Avatar asked Jul 08 '10 14:07

Adam


1 Answers

In your handler, you should check the selectedSegmentIndex to determine which segment was selected:

- (void)valueChanged:(UISegmentedControl *) control {
   switch([control selectedSegmentIndex]) {
      case 0:
         //...
         break;
      case 1:
         //...
         break;
   }
}
like image 121
Jacob Relkin Avatar answered Sep 28 '22 00:09

Jacob Relkin