4

Does anybody here know whether setNeedsDisplay results in an immediate drawRect call and immediate updating of the screen? Or is it merely a queued request? Thanks.

Cezar
  • 52,020
  • 18
  • 84
  • 86
Hupe
  • 41
  • 1
  • 3

1 Answers1

4

The view is not actually redrawn until the next drawing cycle. This simply notifies the system that the view should be redrawn.

See UIView Class Reference

You can apparently accomplish this by setting the content mode to UIViewContentModeRedraw. I haven't done this personally, but the code should be something along the lines of

UIView *redrawView = [[UIView alloc] initWithFrame:frame];
...
redrawView.contentMode = UIViewContentModeRedraw;

See View and Window Modes: Content Modes

Jason George
  • 6,962
  • 8
  • 41
  • 60
  • Do you have any idea how I can force a redraw to happen immediately? Thanks. – Hupe Aug 24 '11 at 21:33
  • setting the contentMode to UIViewContentModeRedraw doesn't in my tests cause an immediate redraw after setNeedsDisplay, only when the bounds change. so I suppose you could jigger the bounds? – natbro Apr 10 '12 at 17:37
  • You might also look here http://stackoverflow.com/questions/1503761/what-is-the-most-robust-way-to-force-a-uiview-to-redraw – Jason George Apr 26 '12 at 06:06