Reputation: 5413
Once the user taps a cell triggering an action, I want to disable the user interaction and then reenable user interaction when the action has finished. Can someone tell me how to do this?
Upvotes: 2
Views: 4600
Reputation: 4517
Just check for the condition in TableView delegate method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *categoryIdentifier = @"Category";
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
//Way to stop to choose the cell selection
if(indexpath.row == 0){
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// OR
cell.userInteractionEnabled=False;
}
//while rest of the cells will remain active, i.e Touchable
return cell;
}
Upvotes: 8
Reputation: 3423
or you can make the selectionStyle when action is running
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Upvotes: 1
Reputation: 8225
Just add a BOOL
variable that you set to true when the action has started. Then implement the -[tableView:willSelectRowAtIndexPath:]
method of the tableview's delegate so that it returns nil
when the variable is currently true for that index path.
Upvotes: 1