- (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