I am trying to work with a segmented control inside a a tableview, then when a user selects an item, I'd like to show a spinner, while some info posts to a webservice.
The problem that I am having is: How do I add a delegate and access the referenced segmented Control, so I can set it's alpha or visibility to NO? Also, what's the best practice for this, I know there's tags, but not sure how they work in this type of situation.
NSArray * segmentItems= [NSArray arrayWithObjects: @"one", @"two", @"three", @"four", @"five", nil];
UISegmentedControl *segmentedControl= [[[UISegmentedControl alloc] initWithItems: segmentItems] retain];
segmentedControl.segmentedControlStyle= UISegmentedControlStyleBar;
segmentedControl.selectedSegmentIndex= -1;
[segmentedControl addTarget: self action: @selector(onSegmentedControlChanged:) forControlEvents: UIControlEventValueChanged];
segmentedControl.frame = CGRectMake(2, 0, 300, 30);
segmentedControl.tintColor= [UIColor grayColor];
Here's my delegate
- (IBAction)onSegmentedControlChanged:(id)sender
{
int clickedSegment= [sender selectedSegment];
}
How do I access the UISegmentedControl from the sender so I can set the visibility Off? I can always set the my object that populates my segmentedControl by extending it, I Just need to figure out how to get a reference to the the cell and the SegmentedControl?