How do I segue to 2 views based on a Segmented Control and an Add button?

后端 未结 2 2038
情深已故
情深已故 2020-12-30 17:08

I have a segmented control in the header of a navigation controller, I want to add an object to a table view controller thats also in this navigation controller.

He

2条回答
  •  抹茶落季
    2020-12-30 17:35

    You make what I call "generic" segues that are not associated with an action/trigger. See my answer here: How to make and use generic segue

    Make 2 of these segues, then in your IBAction method for your segmentedControl call performSegueWithIdentifier:. For example:

    - (IBAction)segmentCtrlChanged:(id)sender {
     UISegmentedControl *seg = sender;
     if (seg.selectedSegmentIndex == 0) 
       [self performSegueWithIdentifier:@"segue1" sender:self];
     else if (seg.selectedSegmentIndex == 1) 
       [self performSegueWithIdentifier:@"segue2" sender:self];
    }
    

提交回复
热议问题