问题描述
我有一个子类UITableViewCell,现在我还需要一个自定义删除按钮。在这种情况下我该怎么办?我在layoutSubView中添加此按钮吗?我已经在单元格的nib文件上有我的删除按钮。
I have a subclassed UITableViewCell and now I also need a custom delete button for this cell. What should I do in this case? Do I add this button in the layoutSubView? I already have my delete button on the nib file of the cell.
我现在在自定义单元格中显示的是在didTransitionToState:(UITableViewCellStateMask)状态下显示按钮。这有效,但它显示删除按钮。我不希望它显示删除按钮,而是希望用户只需按下按钮即可删除该行。我该怎么做?
What I have now in the custom cell is to show the button in the didTransitionToState:(UITableViewCellStateMask) state. This works, however it shows the delete button. I don't want it to show the delete button and instead I want the user to just press the button to delete the row. How can I do this?
推荐答案
您可以将自定义删除按钮链接到单元格的编辑附件视图插座。
You can link your custom delete button to the editing accessory view outlet of your cell.
您还需要阻止单元格进入标准删除模式,只需将其设置为在滑动时进行编辑即可。我的相关问题中有一些细节:
这篇关于定制和自定义UITableViewCell的删除按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!