9

I have three sections in my hypothetical UITableView. I'd like one section that is in editing mode. The rest of the sections to not be in editing mode. Is this possible at all?

2 Answers 2

25

This really shouldn't be a mystery, as it's spelled out clearly in the documentation. Simply use the datasource method

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
2
  • Thanks - I was just looking for this myself and it was much easier to find it here than in the docs :-) May 10, 2009 at 18:57
  • 2
    if you look up UITableViewDelegate & UITableViewDataSource you will see basically everything you will ever need about TableViews
    – jamone
    Feb 23, 2010 at 16:56
0

This worked great for me. In the example below section 0 is not editable whilst the other sections are.

override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
    if indexPath.section == 0{
        return false
    }
    return true
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.