I followed Luke Redpath's suggestion here - Selected UItableViewCell staying blue when selected - to deselect the row when returning to the original table view, but I can't get it working. In fact the method doesn't get triggered.
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES]; }
I suspect this is because the class isn't a UITableViewController
, but a UIViewController
with the tableView
as a property connected up to the NIB.
How would I get the same behavior - ie deselecting when returning?
func tableView(UITableView, willDisplay: UITableViewCell, forRowAt: IndexPath) Tells the delegate the table view is about to draw a cell for a particular row. func tableView(UITableView, indentationLevelForRowAt: IndexPath) -> Int. Asks the delegate to return the level of indentation for a row in a given section.
deselectRow(at:animated:)Deselects a row that an index path identifies, with an option to animate the deselection.
why you just don't deselect it in the delegate method
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With