How to make a cell on a UITableView not selectable?

0 votes
asked Apr 14, 2010 by sheehan-alam

I have a cell that I am inserting to the top of a UITableView. How can I make sure that when the user clicks on the cell, it doesn't show the blue selected indicator?

11 Answers

0 votes
answered Apr 14, 2010 by john-wang

Set the selection style of the UITableViewCell to UITableViewCellSelectionStyleNone

0 votes
answered Apr 26, 2012 by anju

you can do

cell.selectionStyle = UITableViewCellSelectionStyleNone;
0 votes
answered Apr 12, 2013 by malhal

To make it completely non-selectable two things are required:

1- As others said:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

2- You need to implement this delegate method:

// Called before the user changes the selection. Return a new indexPath, or nil, to change the proposed selection.
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
    if(cell.selectionStyle == UITableViewCellSelectionStyleNone){
        return nil;
    return indexPath;
0 votes
answered Apr 18, 2015 by dustin-williams

Swift Syntax:

cell.selectionStyle = UITableViewCellSelectionStyle.None
0 votes
answered Apr 20, 2015 by raymond

Implement this method of UITableViewDelegate

- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;}
0 votes
answered Apr 23, 2015 by eduardo-irias

From the Storyboard set the following for the Table View:

Selection: No Selection

Show Selection On Touch: False

enter image description here

0 votes
answered Apr 24, 2016 by mitch-dalton
myTable.allowsSelection = false
0 votes
answered Sep 15, 2017 by david-villegas

For Swift 3:

cell.selectionStyle = .none
0 votes
answered Sep 15, 2017 by waliyan

for Swift 3 you can use

 cell.isUserInteractionEnabled = false
0 votes
answered Sep 15, 2017 by maven

I am answering from point of view of disabling TableViewCell. You can use the storyboard.

XCode Version 8.2.1 (8C1002)

Select the TableVewCell on storyboard and following will be visible on the right side panel - Utilities.

Utilities Sidebar

Make the Selection: None

That's all!

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter