只有在添加第三个segue时,才会在didSelectRowAtIndexPath之前调用prepareForSegue [英] prepareForSegue called before didSelectRowAtIndexPath only when third segue is added

查看:86
本文介绍了只有在添加第三个segue时,才会在didSelectRowAtIndexPath之前调用prepareForSegue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个segues到3个不同的视图。 2实现没有问题,当第三个被创建时出现问题。

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.

我有以下didSelectRowAtIndexPath方法:

I have the following didSelectRowAtIndexPath method:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@" ----------  did select row");

    if(indexPath.section == 0){
        if(indexPath.row == [self.data count]-1){
            //prior to adding this, everything works
            [self performSegueWithIdentifier:@"MoreComments" sender:self];
        }else{
            [self performSegueWithIdentifier:@"FriendView" sender:friend];
        }
    }else if(indexPath.section == 1){
        if(indexPath.row == [self.data2 count]-1){
            [self performSegueWithIdentifier:@"MorePosts" sender:self];
        }else{
            [self performSegueWithIdentifier:@"FriendView" sender:friend];
        }
    }
}

我有以下prepareForSeque方法:

I have the following prepareForSeque method:

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

一旦我控制从我的单元格拖动到MoreCommentsViewController,我就开始看到错误:

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.

我注意到现在还调用了prepareforseque两次,首先调用prepareforseque,然后再调用,然后再次准备好。

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?

推荐答案

原因是您无法从tableview单元格拖动到多个视图。正如@rdelmar所说,这是错误的。您应该从目标拖动到源视图,然后按照我上面的方式手动处理。

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.

也可以在这里找到:在UITableViewCell上点击进行条件segue

这篇关于只有在添加第三个segue时,才会在didSelectRowAtIndexPath之前调用prepareForSegue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆