Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8933109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:27:40+00:00 2026-06-15T09:27:40+00:00

I have a UITableView that has AllowsMultipleSelectionDuringEditing set to YES. Selecting multiple rows is

  • 0

I have a UITableView that has AllowsMultipleSelectionDuringEditing set to YES. Selecting multiple rows is a big part of my app, and it works great.

The problem is, that on one of my tableView's I don’t want the user to be able to select the first 2 rows when in editing mode, so I have implemented the following:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row == 0 || indexPath.row ==1) {
        return NO;
    }//end

    return YES;

}//end

This works how I thought it would, and doesn’t show the red checkbox graphic or the option to re-sort the rows. BUT, I can still select those rows that are not editable, and call the indexPathsForSelectedRows method and return the indexPaths of those rows.

How can I prevent the user COMPLETELY from being able to select those rows while in editing mode, and prevent touches on those from being returned when calling indexPathsForSelectedRows? Why isn’t canEditRowAtIndexPath: doing this for me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:27:42+00:00Added an answer on June 15, 2026 at 9:27 am

    One way to do this would be to implement – tableView:willSelectRowAtIndexPath: method and check if tableView.editing == YES then return nil for first two cells.

    Something like,

    - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
        if (tableView.editing == YES && indexPath.row < 2 ) 
           return nil;
    
        return indexPath;
    }
    

    You can also set the selectionStyle of these two cells as UITableViewCellSelectionStyleNone in editing mode in cellForRowAtIndexPath method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iOS app with a UITableView that has flexible width, which allow
I have a very simple UITableView that has 3 sections, and 3 rows per
If I have a UITableView that has 4 rows in it then shouldn't the
I have a typical UITableView app that has some cells with some labels.. How
I have an app that has a UITableView and in my Cells I have
I have a UITableView that has a Search Bar. Everything works fine but when
I have a UITableView that has five sections. Just as the title describes cellForRowAtIndexPath
Is it possible to have a UITableView that has a fixed height for all
I have a custom UITableView cell that has a UIImageView sized to the width
I have a UITableView that I am allocating multiple times during the lifetime of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.