prepareForSegue called before didSelectRowAtIndexPath only when third segue is added

I have 3 segues to 3 different views. 2 are implemented with no problem, it is when the third is created that the problems occur.

I have the following didSelectRowAtIndexPath method:

  • White space before separator line into my TableView
  • Turn off or fix Bounce Zoom warning from iPhone XIB compilation
  • Interface Builder and Xcode integration not working
  • Xcode 4.5 storyboard crashing
  • How can I addSubview to UIButton in Interface Builder
  • Can you add IBDesignable properties to UIView using categories/extensions?
  • - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        NSLog(@" ----------  did select row");
        if(indexPath.section == 0){
            if(indexPath.row == [ count]-1){
                //prior to adding this, everything works
                [self performSegueWithIdentifier:@"MoreComments" sender:self];
                [self performSegueWithIdentifier:@"FriendView" sender:friend];
        }else if(indexPath.section == 1){
            if(indexPath.row == [self.data2 count]-1){
                [self performSegueWithIdentifier:@"MorePosts" sender:self];
                [self performSegueWithIdentifier:@"FriendView" sender:friend];

    I have the following prepareForSeque method:

    -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
        if([segue.identifier isEqualToString:@"MorePosts"]){
            MorePostsViewController *mfamvc = segue.destinationViewController;
        }else if([segue.identifier isEqualToString:@"FriendView"]){
            FriendViewController *fvc = segue.destinationViewController;
            fvc.friend = friend;
        }else if([segue.identifier isEqualToString:@"MoreComments"]){
              MoreCommentsViewController *mcvc = segue.destinationViewController;
     = self.data2;

    Before control dragging from my cell to the last view I can see that my program hits didselectrow and then prepareforseque. This makes all the view navigation work perfect.

    As soon as I control drag from my cell to the MoreCommentsViewController I start to see the error:

    nested push animation can result in corrupted navigation bar
    Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

    I notice that now also prepareforseque is being called twice, with prepareforseque being called first, then didselectrow, then prepareforsegue again.

    What am I doing wrong to conditionally go to these different views?

    2 Solutions Collect From Internet About “prepareForSegue called before didSelectRowAtIndexPath only when third segue is added”

    You should use either didSelectRowAtIndexPath or segues from cell, but not both. If you want your didSelectRowAtIndexPath to invoke segues, those segues should not be from the cell to the next scene, but rather from the view controller icon in the bar above the scene:

    segue between view controllers

    You can now select this new segue, go to the “attributes inspector” (option+command+4), and supply a storyboard identifier which you can reference in your code when you call performSegueWithIdentifier.

    The reason is you can’t drag from a tableview cell to multiple views. As @rdelmar mentioned this is wrong. You should drag from the destination to the source view and then handle manually the way I did above.

    Also can be found here: Conditional segue performed on tap on UITableViewCell