views:

471

answers:

3

Hi I'm trying to have my uitableviewcell rendered inactive so that a user can't click but merely say the data in the cell. I attempt to do so with:

UITableViewCell *cell = nil;
if (indexPath.row < factsCount) {
static NSString *FactsCellIdentifier = @"FactsCell";
cell = [tableView dequeueReusableCellWithIdentifier:FactsCellIdentifier];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

However the cell can still be clicked and highlighted.

Thanks for your help!

+2  A: 

Set the cell's selectionStyle to UITableViewCellSelectionStyleNone.

Ole Begemann
the cell is still clickable after I implement this. i have updated my question with the code.
Buffernet
Technically, the cell is still clickable but the user does not see the selection. Of course, you must also ensure that your `tableView:didSelectRowAtIndexPath:` implementation does nothing for this particular cell.
Ole Begemann
A: 

This can be done with:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

or

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
Buffernet
+1  A: 

To disable cell selection you can implement -(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath method in table view delegate and return nil if you don't want cell with given NSIndexPath to be selected.
As already pointed in other answers to disable cell highlighting you should set its selectionStyle property to UITableViewCellSelectionStyleNone.
Also make sure that you set properties correctly when reusing tableviewcells

Vladimir