Why doesn't my UIView subclass redraw after calling setNeedsDisplay?

I have a custom UIView that is a subview of a UITableViewCell. When a cell is drawn, just like my custom view, calling drawRect: in my UIView subclass correctly. When the cell reloads, the view is drawn correctly (called drawRect:).

When a specific event occurs (for example, a timer), I want to redraw the view without reloading the entire cell. (This is not the only view in the cell.)

However, when I call setNeedsDisplayin my subtask, nothing happens.

I assume that when I call my view, the drawRect:resulting image is cached in the backup somewhere so that when I call setNeedsDisplaythat the backup is redrawn on the screen, but my call is drawRect:never made again.

Why is it drawRect:never called again after the cell is created?

EDIT: Moving cells are created from the bottom. i.e.: the UIViewController is loaded from nib, and its view is added to the UITableViewCell.

I made a test case from scratch with a custom view that does not load from nib (generated by the code) and works as expected: it setNeedsDisplayleads to a call drawRect:. It should be something that is either configured in the .xib file, or something that happens differently with the view when it is loaded from the bottom.

+3
1

. XIB - UIView, . IB , " " UIView. , - - , -, .

, !

+1

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


All Articles