定制和自定义UITableViewCell的删除按钮 [英] positioning and customizing delete button for custom UITableViewCell

查看:215
本文介绍了定制和自定义UITableViewCell的删除按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个子类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自定义编辑访问视图 - 未正确解雇

You also need to stop the cell from going into "standard" delete mode, just set it to editing on swipe. There are some details in my related question here : UITableViewCell custom editingAccessoryView - not properly dismissed

我的答案也在这里:自定义编辑访问查看不工作

这篇关于定制和自定义UITableViewCell的删除按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆