How to reformat a custom UITableViewCell in edit mode to place Delete controls?

I have a custom UITableViewCell containing a UILabel where text quantity variables are displayed. The height for the cell is dynamically calculated to accommodate the amount of text.

The problem is that the UILabel / text is not reformatted in edit mode (Delete), as shown in the following screenshots.

I need to use custom cells, not standard textLabel, etc., since other lines have more complex situations with multiple controls than this one with UILabel alone.

a) Here are the table cells with the UILabel control. The height of each cell is dynamically calculated based on the amount of text.

Before edit

b) When editing (red circle) appears in edit mode, which pushes text on the right side of the screen.

Edit control displayed, text off screen

c) Then, when the edit control is selected and the "Delete" button is displayed, it overlaps the text.

Delete button overlaying text

The goal is for the text area (UILabel frame) to decrease its width and increase its height to fit all the text when editing starts with β€œb.” When the β€œDelete” button is displayed, β€œthe height of the text will remain unchanged, and the text, which does not fit, the "..." icon may be truncated and displayed.

+4
source share
1 answer

This should be achieved by making sure that you add the UILabel to the contentView of the UITableViewCell and that you have correctly configured the autoresize masks on the UILabel. Have you tried this before?

+4
source

Source: https://habr.com/ru/post/1384978/


All Articles