IOS development implementation of cell selection when canceling tableView return
When operating on a table UITableView, sometimes when the user selects a table row, it needs to be automatically deselected. To achieve this effect, the principle is that when a table row is selected, the didSelectRowAtIndexPath method will be called. As long as the performSelector is called in this method, the method of unselecting the table row is executed.
The sample code is as follows:
- (void) unselectCurrentRow { // Animate the deselection [ deselectRowAtIndexPath:[ indexPathForSelectedRow] animated:YES]; } - (void)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)newIndexPath { // Any other table management you need ... // After one second, unselect the current row [self performSelector:@selector(unselectCurrentRow)withObject:nil afterDelay:1.0]; }
The delay time can also be set in performSelector. The unselectCurrentRow method completes the selection of canceling the table row and realizes the animation effect.
If you have any questions, please leave a message or go to the community of this site to exchange and discuss. Thank you for reading. I hope it can help you. Thank you for your support for this site!