MJQZ1347
MJQZ1347

Reputation: 2687

Swift / UITableViewCell: Add disclosure indicator, when entering editing mode

I have a custom UITableViewCell class and I want it to show a disclosure indicator, when entering edit mode.

This is my approach:

  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell: CustomCellClass = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! CustomCellClass

    cell.counterTitle.text = "Cell Title"

    if self.tableView.editing {
        cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
    }
    return cell

}

I think I found an answer here, but I have difficulties with translating it into swift: link

Do I need a 2nd custom cell class to solve this?

Thanks

Upvotes: 1

Views: 2141

Answers (1)

Jim Geist
Jim Geist

Reputation: 59

This is a really old question, but in IB in the properties for the UITableViewCell, there's a dropdown for Accessory to set the accessory icon. Under that is Editing Acc. which also has all the standard accessories. If you set one there, it will only show up when editing and will properly animate in and out.

Upvotes: 1

Related Questions