在编辑模式下使用自定义 UILabels 分组 UITableView
我有一个分组的 UITableView,用户可以在其中进入编辑模式并从表中删除行。表格的每个单元格都有两个 UILabels
。当表格进入编辑模式时,自定义 UILabels
会向右推送并超出单元格的右边框。
如果我使用标准 cell.textLabel
,标签会调整大小并保持在单元格的边框内。关于如何使用自定义 UILabels
执行此操作的想法?
I have a grouped UITableView
where the user can enter editing mode and delete rows from the table. Each cell of the table has two UILabels
. When the table enters into editing mode, the custom UILabels
push to the right and go beyond the right border of the cell.
If I use the standard cell.textLabel
, the label resizes and stays within the borders of the cell. Ideas about how to do this with the custom UILabels
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要实现并使用这两个 UITableViewDelegate 方法:
在 willBegin 中,将 UILabel 框架设置为较小的宽度,并在 didEndEditing 上将宽度设置为正常大小。
例如,如果您的 UILabel 被推离边界 50 像素,则在您的方法中执行以下操作:
You need to implement and use these two UITableViewDelegate methods:
In willBegin, set your UILabel frame to have a smaller width and set the width to normal size on didEndEditing.
For example, if your UILabel is getting pushed 50 pixels out of the boundary, in your methods you do: