When will IOS layoutsubviews be called?

Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-size: 14px;"><span style="font-family: Comic Sans MS;">Original: when does layoutsubviews get called?</span></span></p></p><p><p></p></p><p><p><span style="font-family: ‘Courier New‘;"><span style="font-size: 14px;">It ' s important to optimize any UIView Layoutsubviews method you create, as it can be frequently called, and have the potent Ial for creating recursion (triggering a setneedslayout from Layoutsubviews can create a loop that'll grossly affect you R Apps performance). <span style="color: #ff0000;">Layout Subviews is called once per run loop on any view this has had setneedslayout or Setneedsdisplaywithrect:calle D on it. So-in Addition-to-any-time Manually call these methods, it can is useful to know when the UI framework calls SETNEEDSL Ayout/setneedsdisplay as this would trigger Layoutsubviews.</span></span></span></p></p><p><p></p></p><p><p><span style="font-family: ‘Courier New‘;"><span style="font-size: 14px;"><br></span></span></p></p><p><p></p></p><p><p><span style="font-family: ‘Courier New‘;"><span style="font-size: 14px;">。 Init does not cause layoutsubviews to be called (duh)</span></span></p></p><p><p></p></p><p><p><span style="font-size: 14px;"><span style="font-family: Comic Sans MS;">Layoutsubviews is not called when initializing</span></span></p></p><p><p></p></p><p><p><span style="font-family: ‘Courier New‘;"><span style="font-size: 14px;">。 Addsubview causes Layoutsubviews to being called on the view being added, the view it's being added to (target view), and all The subviews of the target view</span></span></p></p><p><p></p></p><p><p><span style="font-size: 14px;"><span style="font-family: Comic Sans MS;">[view addsubview:subview] causes all child view View,subview and view to be called Layoutsubviews</span></span></p></p><p><p></p></p><p><p><span style="font-family: ‘Courier New‘;"><span style="font-size: 14px;">。 Setframe intelligently calls Layoutsubviews on the view have it ' s frame set only if the size parameter of the frame is D Ifferent</span></span></p></p><p><p></p></p><p><p><span style="font-size: 14px;"><span style="font-family: Comic Sans MS;">setframe, The layoutsubviews is called when the Frame's Frame.size is changed and the size is changed before and after the change, Frame.origin will not be called layoutsubviews</span></span></p></p><p><p></p></p><p><p><span style="font-family: ‘Courier New‘;"><span style="font-size: 14px;">。 Scrolling a uiscrollview causes Layoutsubviews to being called on the scrollView, and it ' s Superview</span></span></p></p><p><p></p></p><p><p><span style="font-size: 14px;"><span style="font-family: Comic Sans MS;">Sliding Uiscrollview causes the ScrollView and its parent view to be called Layoutsubviews</span></span></p></p><p><p></p></p><p><p><span style="font-family: ‘Courier New‘;"><span style="font-size: 14px;">。 Rotating a device only calls Layoutsubview on the parent view (the responding Viewcontrollers primary view)</span></span></p></p><p><p></p></p><p><p><span style="font-size: 14px;"><span style="font-family: Comic Sans MS;">Rotating the device only causes the parent view to call Layoutsubviews</span></span></p></p><p><p></p></p><p><p><span style="font-family: ‘Courier New‘;"><span style="font-size: 14px;">。 Removefromsuperview–layoutsubviews is called on Superview only</span></span></p></p><p><p></p></p><p><p><span style="font-size: 14px;"><span style="font-family: Comic Sans MS;">Removefromsuperview will only be the parent view call Layoutsubviews</span></span></p></p><p><p></p></p><p><p><span style="font-family: ‘Courier New‘;"><span style="font-size: 14px;"><br></span></span></p></p><p><p></p></p><p><p><span style="font-size: 14px;"><span style="font-family: Comic Sans MS;">Suggest you look at the original text, above is just excerpts</span></span></p></p><p><p></p></p><p><p>When will IOS layoutsubviews be called?</p></p></span>

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.