I have a UITableView with cells that push viewControllers onto the stack when selected. The child viewControllers take user input and then pops off the stack.
When the child viewController is popped, I want the parent tableView to update the value of the selected cell AND then deselect the row. I can update the cell using reloadData, and I can deselect the row using deselectRowAtIndexPath – but I can’t do both at the same time.
I understand why this is – reloadData deselects the cell implicitly, and deselectRowAtIndexPath deselects it explicitly, but I find it curious that I can’t find anyone wanting to achieve the same reload/deselect behavior. What am I missing here?
All code is in viewWillAppear:animated – I can get close if I put deselectRowAtIndexPath in viewWillAppear and reloadData in viewDidAppear, but this isn’t what I want.
When you reload a cell, it automatically gets deselected. That’s because you don’t set a cell’s
selectedproperty toYESintableView:cellForRowAtIndexPath:. So you will have to deal with this differently. Either identify that the cell atindexPathneeds to beselectedand appropriately set itsselectedproperty toYESintableView:cellForRowAtIndexPath:or select it after you reload the data. In such case, you can execute the following methods –The order of steps are :-
This way I think you can get the effect you want.