如何在编辑模式下重新格式化自定义UITableViewCell以容纳Delete控件? [英] How to reformat a custom UITableViewCell during editing mode to accommodate Delete controls?

查看:43
本文介绍了如何在编辑模式下重新格式化自定义UITableViewCell以容纳Delete控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义UITableViewCell,其中包含一个UILabel,其中显示可变数量的文本.动态计算单元格的高度以适应文本量.

I have a custom UITableViewCell that contains a UILabel where variable amounts of text are displayed. The height for the cell is dynamically calculated to accomodate the amount of text.

问题在于,如以下屏幕截图所示,在编辑模式(删除)期间UILabel/文本未重新格式化.

The problem is the UILabel/text is not being reformatted during the Edit mode (Delete) as shown in the following screen captures.

我需要使用自定义单元格,而不是标准的textLabel等,因为与只有一个UILabel的行相比,其他行具有多个控件的情况更为复杂.

I need to use custom cells rather than the standard textLabel etc. as other rows have more complex situations w/ multiple controls compared to this one w/ just a single UILabel.

a)这是带有UILabel控件的表单元格.每个单元格的高度是根据文本量动态计算的.

a) Here's the table cells w/ the UILabel control. The height of each cell is dynamically calculated based upon the amount of text.

b)当编辑"模式启动时,将显示编辑控件(红色圆圈),该控件将文本推离屏幕右侧.

b) When the Edit mode starts the editing control (red circle) is displayed which pushes the text off the right side of the screen.

c)然后选择编辑控件并显示删除按钮时,它与文本重叠.

c) Then when an editing control is selected and the Delete button is displayed it overlaps the text.

目标是使文本区域(UILabel框架)在编辑开始"b)"时减小其宽度并增加高度以容纳所有文本.当删除"按钮显示为"c)"时,文本高度将保持不变,不适合的文本可以被截断,并显示省略号"...".

The objective is to have the text area (UILabel frame) reduce it's width and increase the height to accommodate all the text when editing starts "b)". When the Delete button is displayed "c)" the text height would stay the same and the text that does not fit can be truncated and an elipsis "..." displayed.

推荐答案

这应该可以通过以下方法实现:确保将UILabel添加到UITableViewCell的contentView中,并且已在UILabel上正确设置了自动调整大小掩码.你已经尝试过了吗?

This should be attainable by making sure that you're adding the UILabel to the contentView of the UITableViewCell and that you've properly set the autoresize masks on the UILabel. Have you already tried that?

这篇关于如何在编辑模式下重新格式化自定义UITableViewCell以容纳Delete控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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