I have a button that I would like to perform different code when each of 3 segmented controls are selected. EX) If segment1 is selected, Code1 will be executed when theButton is pressed. If segment2 is selected, Code2 will be executed when theButton is pressed. I haven't worked with Segmented Controls before, anyone know how to do this?
Assuming you have target action setup on your button and an IBOutlet to your segmented control you could do the following.
- (IBAction)buttonPressed:(UIButton *)sender
{
NSInteger selectedIndex = self.segmentedControl.selectedSegmentIndex;
switch(selectedIndex)
{
case 1: [self methodOne]; break;
case 2: [self methodTwo]; break;
case 3: [self methodThree]; break;
default : break; //Do nothing
}
}