How do you disable selecting only a single cell in a UITableView? I have several, and I only want the last to be disabled.
+1
A:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = ...
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
camilin87
2010-08-30 18:57:02
This will prevent the cell from appearing to be selected, but `tableView:didSelectRowAtIndexPath:` will still be called.
Brian
2010-08-30 19:39:32
+2
A:
-(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
Aaron Saunders
2010-08-30 19:11:35
This will prevent the cell from actually being selected, but it will still be highlighted when the user touches it
Brian
2010-08-30 21:07:19
Sorry, need to add UITableViewCellSelectionStyleNone style to the cell
Aaron Saunders
2010-08-30 21:15:58
+1
A:
Duplicate from http://stackoverflow.com/questions/2267993/uitableview-how-to-disable-selection-for-some-rows-but-not-others
Read all the answers, not just the "accepted" one.
Nir Levy
2010-08-30 19:16:20