The implementation of IOS development cancels the problem selected by the cell when tableview returns

Time:2022-1-2

The implementation of IOS development cancels the problem selected by the cell when tableview returns

When operating on the uitableview table, sometimes the user needs to automatically cancel the selection after selecting the table row. To achieve this effect, the principle is to select the table row and call the didSelectRowAtIndexPath method, as long as we call performSelector to execute the method of unchecking the table row in this method.

The example code is as follows:


- (void) unselectCurrentRow
{

 // Animate the deselection

 [self.tableView deselectRowAtIndexPath:[self.tableView 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];

} 

You can also set the delay time in performselector. Unselectcurrentrow method cancels the selection of table rows and realizes the animation effect.

If you have any questions, please leave a message or go to the community of this site for exchange and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!

Recommended Today

Click the button in H5 to download the picture

In the development of uni app project, one requirement is to click the button to download multiple pictures, and the picture path is returned from the background. (saveimagetophotosalbum in uni app is not available) ——————- the following code is obtained by referring to other people’s methods and my own personal practice Method 1:      var […]