How to stop text in a UITableViewCell running in the area used by the disclosure indicator?

I show long text in a cell and resize the height of the cell with heightForRowAtIndexPath. However, when the text is displayed, it falls into the area used by the disclosure indicator (empty).

When such a line is selected and a checkmark is displayed, the text will reformat itself so as not to use the indicator area, as a result of which I do not want a visual effect.

If there was an accessory UITableViewCellAccessoryBlank(and not UITableViewCellAccessoryNone), perhaps the text would not be transferred to this area when displayed. Should I create a custom cell and place my own shortcut, or is there an easier way?

+3
source share
1 answer

First of all, I do not see a property call UITableViewCellAccessoryBlankin a reference to a class of the UITableView class , so I do not think this will work.

I think you have 2 options:

  • Create a custom cell as you suggest.
  • Customize the textLabel of your cell to change its contentMode.

I read this in the UILabel class reference :

The default content mode for the UILabel class is UIViewContentModeRedraw. This mode forces the view to redraw its contents each time its bounding box changes. You can change this mode to change the inherited contentMode property of the class.

, textLabel , , .

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath:

cell.textLabel.contentMode = UiViewSomeContentMode;

. , , .


, contentMode . UITableViewCell .

, !

+1

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


All Articles