I have a button which has an action that gives a push to another view. My goal is to make this button to open different views according to the selected segment. For example: I have a button called "Request" and have a control segment with two segments, called "Pizza Salt" and "Sweet Pizza." When selected, for example, "Pizza Salt" in the segment and then immediately click the "Request" button, I want to open a view to the menu of "Salt Pizza.", And selected "Sweet Pizza" I want the button to open another view with the menu of the "Sweet Pizza."
Note: I already have the two controllers ready with views.
What code do I use?
My code:
- (IBAction)changeButtonCode:(id)sender {
if (_firstSegmentSixthView.selectedSegmentIndex == 0);
}
- (IBAction)pushToNextView:(id)sender {
}
Upon pressing the request button:
if (_firstSegmentSixthView.selectedSegmentIndex == 0) //salty
{
ViewController1 *vc1 = [[ViewController1 alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
else if (_firstSegmentSixthView.selectedSegmentIndex == 1) //sweet
{
ViewController2 *vc2 = [[ViewController2 alloc] init];
[self.navigationController pushViewController:vc2 animated:YES];
}