I'm using swipe to delete function's
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//add code here for when you hit delete
NSLog(@"UITableViewCellEditingStyleDelete");
[liste removeObjectAtIndex:indexPath.row];
[self refreshTableView];
}
}
and I need to hide an UImage on the selected Cell, so I'm using this code
- (void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath;{
cellTodelete = (ListeRestoCell *) [self.tableView cellForRowAtIndexPath:indexPath];
if(cellTodelete.eventImage.hidden==NO) {
a = 1 ;
cellTodelete.eventImage.hidden = YES ;
}
return;
}
This work great, the only problem is that my Uimage is hidden even if the button Delete was not clicked, so I need to show image again if the button delete was not clicked. How can I do this?
Do like this,
In .h
BOOL isDeleted;
NSIndexPath *selIndexPath;
In .m
loadView
isDeleted = NO;
/
- (void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath;{
selIndexPath = indexPath;
cellTodelete = (ListeRestoCell *) [self.tableView cellForRowAtIndexPath:indexPath];
if(cellTodelete.eventImage.hidden==NO) {
a = 1 ;
cellTodelete.eventImage.hidden = YES ;
}
return;
}
/
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
isDeleted = YES;
//add code here for when you hit delete
NSLog(@"UITableViewCellEditingStyleDelete");
[liste removeObjectAtIndex:indexPath.row];
[self refreshTableView];
}
}
/
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(!isDeleted && selIndexPath!=nil) {
cellTodelete = (ListeRestoCell *) [self.tableView cellForRowAtIndexPath:selIndexPath];
cellTodelete.eventImage.hidden = NO ;
}
}