Issue with deselectRowAtIndexPath in tableView

后端 未结 2 1174
一生所求
一生所求 2021-01-16 08:58

I have a cell with a few lines of text which changes colour when selected/highlighted. The problem is that as the new viewController is being pushed, the deselection animati

2条回答
  •  滥情空心
    2021-01-16 09:54

    I think the general paradigm used with table views and pushing new VCs is that you deselect the table row in your viewWillAppear:animated method. Then as the VC is popped, they see which row had been used to navigate to that VC.

    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
    
        [self.myTableView deselectRowAtIndexPath:[myTableView indexPathForSelectedRow] animated:YES];
    
    }
    

    so remove deselectRow from your didSelectRowAtIndexPath method.

提交回复
热议问题