View & Draw

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.