I have a Segmented Control that I'm using to switch between three view controllers. My first tableview is embedded in a navigation controller where the segmented control is in the navigation controller. I also have two custom segues in the storyboard (with animations coming from the left and right). In my "main" controller class - the middle of the segmented control - I use this code
- (IBAction)indexChanged:(id)sender {
if ([sender selectedSegmentIndex] == 0) {
[self performSegueWithIdentifier:@"leftSegue" sender:self];
}
else if ([sender selectedSegmentIndex] == 1){
}
else {
[self performSegueWithIdentifier:@"rightSegue" sender:self];
}
}
This works great for those two controllers. When those view controllers are put on the screen, I can still move between the far left and right controllers, but going back to the main controllers is crashing under each attempt I've tried. I think it has to do with me not understanding either the self
that I'm sending the performSegueWithIdentifier
message or self
that I'm passing to sender:
.
Example: If in the else if ([sender selectedSegmentIndex] == 1){}
I create a new segue, with a unique identifier coming from either of the two new controllers, the application crashes saying "Receiver has no segue with identifier" when it is spelled correctly. Who is the receiver in this example?
Edit: I've added my current storyboard pictures here. The top two are the custom segues, and the middle two are modal and push, specific for the requirements.
Edit2: Using methods like self.navigationController.viewControllers[0]
finds the correct view, but it doesn't allow me to switch back to the initial controller- it redraws it an loses the navigation bar.