Hide Row(Multiple Row) After Clicked in TableView

216 Views Asked by At

I Am developing one Application. This Application Contain TableView If i once click any one row that row i want to hide after some operation, Can Any one help ?

1

There are 1 best solutions below

0
Mehul Patel On BEST ANSWER

I have a suggestion for you:

@property (nonatomic, strong) NSArray   *tableItems;
@property (nonatomic) NSInteger         hideIndex;

Add UITableView delegate methods and in didSelectRowAtIndex method

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

// Store index of row to hide.
self.hideIndex = indexPath.row;   
}

Create your operation method

- (void) doOperation {

// Remove index from table datasource.
@try {
    NSMutableArray *tempArray = [NSMutableArray arrayWithArray:self.tableItems];
    [tempArray removeObjectAtIndex:self.hideIndex];

    self.tableItems = [NSArray arrayWithArray:tempArray];
    tempArray = nil;
    [self.tableView reloadData];
}
@catch (NSException *exception) {
    NSLog(@"Handle exception");
}
}

So that on next reload of UITableView will show remaining cells. And remove your selected cell.