更改 UITableViewCell 的编辑控件图像 [英] Change editing control image for UITableViewCell

查看:30
本文介绍了更改 UITableViewCell 的编辑控件图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以更改 UITableViewCell 的多行选择的编辑控件图像.如果可以通过 UITableViewCell 的任何默认函数或者我们必须自己自定义它,如果可以的话,任何人都可以给我任何参考来做.

Is it possible to change the editing control image for multiple row selection for UITableViewCell. If it is possible via any default function of UITableViewCell or we have to customize it on our own, if so could anyone give me any reference to do it.

提前致谢.

推荐答案

OP 实际上是想更改编辑控件.这是将单元格更改为编辑模式时出现在单元格左侧的加号或减号.您实际上无法更改图像,但您可以做的是假更改图像,步骤如下:

The OP is actually wanting to change the editing control. That is the plus or minus that appears to the left of the cell when you change it to editing mode. You can't actually change the image, but what you can do is fake changing the image, here are the steps:

  1. 创建一个 UITableViewCell 子类.
  2. 覆盖 initWithCoder:.在该方法中,将 UIView 添加到 self.backgroundView.
  3. 覆盖 willTransitionToState:.您无需在此处实际添加任何内容,但添加此方法覆盖可防止单元格添加系统编辑控件.
  4. 将您想要作为编辑控件的图像作为子视图添加到 self.backgroundView.

现在,当表格进入编辑模式并且单元格将内容向右移动时,您将看到添加到背景视图中的图像.这样做的副作用是当您触摸新图像时它不会收到触摸.对于我的情况,我将 tableView.allowSelectionDuringEditing 设置为 YES 并处理 tableView:didSelectRowAtIndexPath: 中的选择.

Now, when the table enters editing mode and the cells shift the content to the right, you will see the image that you added to the background view. The side effect of this is that it will not recieve the touch when you touch your new image. For my case I set tableView.allowSelectionDuringEditing to YES and handled selection in tableView:didSelectRowAtIndexPath: in my table view controller.

这篇关于更改 UITableViewCell 的编辑控件图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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