redribben icon

reload cell when switch triggered

redribben | PRO | 02/04/15 03:20:34 AM UTC | 0 ⭐ | 431 👁️ | Never ⏰ | []
Objective C |

0 B

|

None

|

0 👍

/

0 👎

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ...
    ...
    [cell.cellSwitch addTarget:self action:@selector(switchUD:) forControlEvents:UIControlEventValueChanged];
    [cell.cellSwitch setTag:indexPath.row];
    ...
    ...
return cell
}
 
 
 
-(void)switchUD:(id)sender {
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection:0];
    NSArray* rowsToReload = [NSArray arrayWithObjects:indexPath, nil];
    [self.tableView reloadRowsAtIndexPaths:rowsToReload withRowAnimation:UITableViewRowAnimationAutomatic];
}

Comments