how could i forbid a tableviewcell to be selected

As usual, when a tableviewcell is touched, it will be selected. But now i need one cell in my tableview never be could i forbid a tableviewcell to be selected?

After modifying didSelectRowForIndexPath: method. It works now. Thx ALl:) Once the cell (need to be forbidden) is selected i just use the selectRowAtIndexPath method to select the former selected cell to be selected again.


In your didSelectRowForIndexPath: method, you can check if the cell meets your quality standards and accordingly, show a UIAlertView or go ahead if it meets the requirements

The correct way is to use tableView:willSelectRowAtIndexPath:. Unlike all the other answers this will work with segues too ;-)

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath should not be selected) {
        // if another indexPath should be selected instead return this indexPath
        return nil;
    return indexPath;

You can disable the user Interaction for that very cell or set the selection Style None for that cell. Hope that helps!

In your -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method add the following line to the cell you want to be not selectable:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

Hope it helps


And in your -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath method add the following at the beginning:

if (indexPath == indexPathOfTheCellThatShouldntBeSelected) return;

Need Your Help

REST API and static pages (best solution)

php android api rest url

I am relatively new in API development. I often face with different problems and have a lot of questions. Major question is "How to implement something following best practices and patterns".

NAnt and dual platform build - best way to build on Windows AND Mono/Linux

.net linux build-process mono nant

I'm new to NAnt but have some experience with Ant and CruiseControl.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.