1

I have a TableView that pulls in a custom cell of the custom class GroupTableView. I'm able to scroll through without any issue when not in edit mode (all the data remains in the right cells etc.). However, when I go into edit mode, the delete button disappears as I scroll through the table.

Here's my code for the tableview:

 func tableView(tableView: UITableView!, numberOfRowsInSection section:    Int) -> Int {
        return groups.count
    }

    func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {

        var cell: GroupTableView = tableView.dequeueReusableCellWithIdentifier(groupCellID) as GroupTableView

        if (cell == nil) {
            cell = GroupTableView(style: UITableViewCellStyle.Default, reuseIdentifier: groupCellID)
        }

        cell.groupName.text = groups[indexPath.row].groupName
        cell.groupOwner.text = "OwnerID: \(groups[indexPath.row].ownerID)"
        cell.numPosts.text = groups[indexPath.row].numPosts

        return cell;
    }

    func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
        if (groupTableView.editing == true)
        {
            self.performSegueWithIdentifier("segueToGroupDetail",sender:self)
        }
        else
        {
            self.performSegueWithIdentifier("segueToLinkView",sender:self)
        }
    }

Here's my code to enable edit mode:

  override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationItem.leftBarButtonItem = self.editButtonItem()
}

  override func setEditing(editing: Bool, animated: Bool)
    {
        super.setEditing(editing,animated:animated)
        groupTableView.setEditing(editing,animated:animated)
    }

This is written in swift, but hopefully conceptually similar to how it would be done in objective-c.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user1031648
  • 553
  • 1
  • 4
  • 9
  • Is it because after you scroll off screen the cell is reused? – veovo Jul 22 '14 at 01:54
  • I agree it may be related to cell reuse, but none of the other elements of the cell disappear or get repeated (in both the normal view and edit mode), so I'm not sure why the delete button disappears in edit mode. – user1031648 Jul 22 '14 at 07:06
  • @user1031648 Have a look at [this](http://stackoverflow.com/questions/43061210/delete-button-disappeared-on-scrolling-in-edit-mode-of-uitableview) – Anurag Sharma Mar 29 '17 at 07:58

0 Answers0