I have two UIbutton
s, and I want to assign the two buttons to a UITextView
so that when one of the buttons is pressed, the text view content changes from what it had when previous button was pressed. I want to do this using a segmented control. How do I assign each segmented control different selectors in the NIB file?
Asked
Active
Viewed 400 times
0
2 Answers
1
As mentioned you have to connect your IBAction to your UISegmentedControl
in IB with the valueChanged:
option (i think you usually set touchUpInside for uibuttons), then try this
- (IBAction)changeType:(id)sender{
//segControl is an instance of UISegmentedControl
segControl = sender;
if(segControl.selectedSegmentIndex==0){
//do something
}
else if (segControl.selectedSegmentIndex==1){
}//and so on
}
Hope this helps.

Mat
- 7,613
- 4
- 40
- 56
0
You can assign the segment control to a single IBAction
. In that method use segment control's selectedSegmentIndex
to identify which section is pressed and call the later functions accordingly.

Ravi Gautam
- 960
- 2
- 9
- 20

Ahmed
- 772
- 1
- 9
- 26