- 1 Label
- 1 Segment Control
The Code
Play the video to get a step by step walkthrough and all code can be copy and pasted ViewController.h IBOutlet UILabel *label; IBOutlet UISegmentedControl *segmentController; } -(IBAction)segmentbutton:(id)sender; |
ViewController.m
-(IBAction)segmentbutton:(id)sender {
if (segmentController.selectedSegmentIndex == 0) {
label.text = @"Button 1 Was Selected";
}
if (segmentController.selectedSegmentIndex == 1) {
label.text = @"Button 2 Was Selected";
}
if (segmentController.selectedSegmentIndex == 2) {
label.text = @"Button 3 Was Selected";
}
if (segmentController.selectedSegmentIndex == 3) {
label.text = @"Button 4 Was Selected";
}
if (segmentController.selectedSegmentIndex == 4) {
label.text = @"Button 5 Was Selected";
}
}
No comments:
Post a Comment