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!

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;
   }
}

Need Your Help

Circular view and color and cifilter with animation

ios xcode image filter effect

I'm working on an app, and i need to make an effects when the user click on a UIButton.

Display/hiding bottom nav bar - Objective C

ios objective-c uitabbarcontroller uitabbar

I have a UITableViewController and a TabBar inside of the TableView and I want to be able to display that TabBar at the bottom of the IPhone screen and not at the bottom of the Table Cells So The ...