DimonDeveloper
DimonDeveloper

Reputation: 137

How to disable touch row in uitable without disable highlight

In UITable i get index of selected row. And when i get index of row i want disable her that then it can not be pressed but highlight should remain. And when i click another row it is highlight and previous row is enable and highlight is disable.

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    CellIndex = indexPath.row;
    [self.containerViewController swapViewControllers:CellIndex];
}

enter image description here

I want nothing happens if you click on the row that is already pressed. Thanks everyone for help.

Upvotes: 0

Views: 55

Answers (1)

Stonz2
Stonz2

Reputation: 6396

Keep a variable that knows which was the last row pressed, and check in tableView:didSelectRowAtIndexPath:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if(previouslySelectedIndexPath == indexPath)
        return;
    previouslySelectedIndexPath = indexPath;

    CellIndex = indexPath.row;
    [self.containerViewController swapViewControllers:CellIndex];
}

Upvotes: 2

Related Questions