I was wondering if anyone was aware of a way to deselect a table view after a delay?
I am using the deselectRowAtIndexPath
method. I just want the highlighting to show up for a second before deselecting it.
Thanks!
I was wondering if anyone was aware of a way to deselect a table view after a delay?
I am using the deselectRowAtIndexPath
method. I just want the highlighting to show up for a second before deselecting it.
Thanks!
If what you are trying to accomplish is: Tap a row, see highlight, highlight goes away you can:
In didSelectRowAtIndexPath
//after you do whatever your doing when a row is selected
UITableViewCell *cell [tableView cellForRowAtIndexPath:indexPath];
[cell setSelected:NO];
This will produce the effect you're looking for if I haven't misunderstood you.
[self performSelector:@selector(deselect:) withObject:self afterDelay:0.33];
To add a slight delay when deselecting a tableview cell, you need to add the following to tableView(_:didSelectRowAt:)
:
DispatchQueue.main.asyncAfter(deadline: .now() + 0.33) {
self.deselectRow(at: indexPath, animated: true)
}
I was able to do that using
[tableView deselectRowAtIndexPath:indexPath animated:YES];
Another way to do this would be:
and then create a method
deselect
that callsdeselectRowAtIndexPath