When an IOS application is launched, it starts a run loop. The run loop ' s job is to listen for events,
such as a touch. When a event occurs, the run loop then finds the appropriate handler methods for the
Event. Those handler methods call other methods, which call more methods, and so on. Once all of the
Methods has completed, control returns to the run loop.
When the run loop regains control, it checks a list of ' dirty views ' –views that need to be rerendered
Based on what happened in the recent round of event handling. The run loop then sends
The drawrect:message to the "before all" in the hierarchy is composited
Together again.
These optimizations–only re-rendering views the need it and only sending drawrect:once per
Event–keep IOS interfaces Responsive.
To get a view on the list of dirty views, you must send it the message setneedsdisplay. The
Subclasses of UIView that is part of the IOS SDK send themselves setneedsdisplay whenever their
Content changes.
For example, an instance of UILabel would send itself setneedsdisplay when it's sent
SetText:, since changing the text of a label requires the label to re-render its layer. In Custom UIView
Subclasses, you must send this message yourself.
There is another possible optimization when Redrawing:you can mark only a portion of a view as
Needing to be redrawn. This is do by sending setneedsdisplayinrect:to a view.
View & Draw