I have placed an UISegmentedControl into my XIB file. Basically, when the the second tab of the control is tapped (aka segment 1, the first segment is segment 0), I want to unhide a text field. I know how to unhide the text field, but how do I detect which part of the segmented control the user has tapped?
[textField setHidden:NO];
Create an IBAction like the one below and connect it to the valueChanged action in Interface Builder.
- (IBAction)segmentedControlChanged:(id)sender
{
UISegmentedControl *s = (UISegmentedControl *)sender;
if (s.selectedSegmentIndex == 1)
{
[countTextField setHidden:NO];
}
}
You should hook up your segmeted controls valueChanged
action in IB to a method in your view controller that checks your segmented controls selectedSegmentIndex
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With