Waqar
Waqar

Reputation: 220

How to deselect the selected rows?

I'm new to ios programming. I'm trying to find a way to deselect the rows that are selected. I've tried searching for the solution but couldn't get it done with all of the possible answers. Here is the code..

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

UIAlertView *messageAlert = [[UIAlertView alloc]initWithTitle:@"Row Selected" message: [recipes objectAtIndex:indexPath.row] delegate:nil cancelButtonTitle:@"ok" otherButtonTitles: nil];

//Display alert message
[messageAlert show];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
//[tableView deselectRowAtIndexPath:indexPath animated:NO]; }

Upvotes: 0

Views: 53

Answers (1)

Bisca
Bisca

Reputation: 6763

You can do this, anyway, you should search in Google before

for (NSIndexPath *indexPath in tableView.indexPathsForSelectedRows) {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}

Upvotes: 2

Related Questions