Reading Notes-basics, basics of Reading Notes

Source: Internet
Author: User

Reading Notes-basics, basics of Reading Notes

1. iOS system architecture is divided into four layers: Cocoa Touch layer, Media layer, Core Services layer and Core OS layer.

2. Auto Layout is first applied to the development of Mac 0 s x 10.7. It defines a set of constraints for the view Layout, and the constraints define the relationship between views and graphs on the two interfaces.

3. AppDelegate is the application delegate object, inherits the UIResponder class, and implements the UIApplicationDelegate delegate protocol. The former enables the Sub-class AppDelegate to process the corresponding time, while the latter delegation protocol enables it to become the application delegate object, which can respond to the application's lifecycle. Correspondingly, the Child classes of AppDelegate can also implement these two functions.

4. The ViewController class inherits from the UIViewController class. It is a View Controller class and plays the role of the Root View and user event control class in the project.

5. nib is equivalent to xib. Generally, a project can contain multiple xib files. An xib file corresponds to one view controller and multiple views, A project only needs a storyboard file. The story board can also describe the navigation relationships between interfaces. In fact, the story board is a description file of multiple xib file sets, also in xml format.

6. Application lifecycle: as the delegate object of an application, the AppDelegate class calls back different methods at different stages of the application lifecycle.

The following describes the five statuses of iOS apps.

Not Running (Not Running ). The application is not running or terminated by the system.

Inactive ). The application is in the foreground status, but cannot handle the event.

Active (foreground activity status ). The application enters the foreground status and can handle the event.

Background (Background status ). After the application enters the background, the code can still be executed. If there is executable code, the code will be executed. If there is no executable code or the executable code is completed, the application will immediately become suspended.

Suspended ). A suspended application enters a "Frozen" State and cannot execute code. If the system memory is insufficient, the application will be terminated.

During the application state transition process, the iOS system calls back some methods in AppDelegate and sends some corresponding notifications:

Application: didfinishlaunchingwitexceptions: This method is called and notified when the application is started and initialized. The Root View Controller is instantiated at this stage.

ApplicationDidBecomeActive: This method is called and a notification is sent when the application enters the foreground and is active. At this stage, the UI status can be restored.

ApplicationWillResignActive: This method is called and a notification is sent when the application changes from active to inactive. At this stage, you can save the UI status.

ApplicationDidEnterBackground: This method is called and a notification is sent when the application enters the background. In this phase, user data can be stored and some resources (such as database resources) can be released)

ApplicationWillEnterForeground: This method is called and a notification is sent when the application enters the foreground but is not active. At this stage, user data can be restored.

ApplicationWillTerminate: This method is called and a notification is sent when the application is terminated, except when the memory is cleared. In this phase, some resources are released and user data can be saved.

Below we will take a few application scenarios as an example (the specific analysis will not be written, and we believe everyone can understand it ):

Application startup scenario: Not running → Inactive → Active

Application exit scenario: the state transition process in this scenario can be divided into two situations, which can be run or suspended in the background or not. Application does not run in background can control the two statuses in the product property file.

(1) The application can be run or Suspended in the Background: Active → Inactive → Background → suincluded

(2) Applications cannot be run or Suspended in the Background: Active → Inactive → Background → suincluded → Not running

Suspension and re-running scenario: suincluded → Background → Inactive → Active

Memory cleanup-application termination scenario: Background → suincluded → Not running

7. View Lifecycle

In different life cycles of a view, the View Controller calls back different methods.

The viewDidLoad method is called when the View Controller is instantiated and the view is loaded into the memory. The view does not appear at this time. In this method, we usually initialize the control view.

After the view is visible, viewWillAppear: method and viewDidAppear: method are called. The viewWiiDisappear: And viewDidDisappear: methods are called before and after the view is invisible. The four methods call the corresponding methods of the parent class to implement their functions. During encoding, the location of the method can be adjusted as needed, as shown below:

1-(void) viewWillAppear :( BOOL) animated 2 {3 [super viewWillAppear: YES];

Related Article

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.