Syed Absar
Syed Absar

Reputation: 2284

Another Button at UITableView Editing Mode

I need an additional button next to the Delete button when in editing mode of UITableView Cells. Any suggestions for the purpose is appreciated. Thank You.

Upvotes: 0

Views: 1113

Answers (2)

bshirley
bshirley

Reputation: 8357

cell.editingAccessoryType = UITableViewCellAccessoryCheckmark;

or some other value than "check"

or

cell.editingAccessoryView = [UIButton buttonWithType:UIButtonTypeInfoDark];

or with some other value than the info button, with it's target set to something appropriate

an accessory view trumps a type

Upvotes: 0

Martin Hering
Martin Hering

Reputation: 429

I would suggest you first subclass UITableViewCell. In the respective init method you create the button and add it to the contentView as a subview. Make the button hidden. After that you overwrite layoutSubviews and position the button on your content view by setting the frame property of the button. Then also subclass willTransitionToState: and check if the state is UITableViewCellStateShowingEditControlMask. If that's the case make the button visible. If not hide it.

Note: If you add an additional button to the UITableViewCell you also need to adjust the textLabel frame and other stuff to not overlap the button's rectangle.

Upvotes: 2

Related Questions