Stanford IOS Learn Notes-5

Source: Internet
Author: User

Today, we summarize the View Controller lifecycle and AutoLayout, which is the 8th section of the course.

1. View Controller Lifecycle

In fact, after listening to the course two times, I still can not accurately summarize the life cycle of each controller is how long. Controller, the C in MVC, begins the life cycle of the controller after MVC is created, which is easy to understand. But what I'm puzzled about is the end of the MVC life cycle.

    1. How do you define the results of the MVC life cycle first? The Deinit function of the controller is called (memory free)? Or is it the view disapper? For MVC, which calls segue, as long as the MVC is removed from the desktop (disapper), it will no longer appear, because every call to Segue is a new MVC generation. The Disppear and deinit of MVC are not at the same time, as seen in the classroom examples. When MVC disappear, it does not call Deinit until a new MVC of the same type is generated, and the disappear MVC is init.
    2. I think it's time to define the end of the life cycle of the controller based on memory release. But the question is, is this memory release time-definite?

Now these two questions themselves still can not answer, can only consult others later or in the time question slowly pondering. But this is not the focus of this lesson. The focus of this lesson is to let you know the main operational nodes of the MVC lifecycle, the corresponding APIs, and then implement the specific work by overwriting the appropriate API functions.

To summarize, there are several stages in the View controller's lifecycle:

    • Instantiated (from storyboard usually)
    • Awakefromnib
    • Segue Preparation happens
    • Outlets Get Set
    • Viewdidload
    • These pairs'll be called each time your controller ' s view goes on/off screen ...
      • Viewwillappear and Viewdidappear
      • Viewwilldisappear and Viewdiddisappear
    • These ' geometry changed "methods might is called at any time after viewdidload ...
      • Viewwilllayoutsubviews (... then AutoLayout happens and then ...) viewdidlayoutsubviews
    • If memory Get low, you might get ...
    • Didreceivememorywarning
2. AutoLayout

In fact, this lesson does not say much about AutoLayout. The main thing is size class. The size class concept is easy to understand.

The inherited protocol is uitraitenvironment, and this protocol has an attribute traitcollection, an API Traitcollectiondidchange.

This blog has a good knowledge of the compact and regular: Http://www.learnswift.io/blog/2014/6/12/size-classes-with-xcode-6-and-swift

Read it often.

Stanford IOS Learn Notes-5

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.