开发者

Another Button at UITableView Editing Mode

开发者 https://www.devze.com 2023-02-04 00:29 出处:网络
I need an additional button next to the Delete button when in editing mode of UITableView Cells. Any suggestions for the purpose is appreciated. 开发者_Go百科Thank You.I would suggest you first subcla

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


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消