Disable selection of a single UITableViewCell

前端 未结 9 2078
迷失自我
迷失自我 2021-01-31 08:32

How do you disable selecting only a single cell in a UITableView? I have several, and I only want the last to be disabled.

9条回答
  •  囚心锁ツ
    2021-01-31 09:20

    -(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if ([self numberOfRowsInSection] == [indexPath row]) {
            return nil;
        } else {
            return indexPath;
        }
    }
    

    the last row of the table will not be selected

提交回复
热议问题