IOS study notes, ios learning materials

Source: Internet
Author: User

IOS study notes, ios learning materials

1. Three methods to create a controller:

2. When the program starts, it looks for the Main Interface. If the Main Interface is found, the default storyboard is automatically loaded. The loading process is roughly as follows:

3. After the storyboard is loaded, use the instantiateViewControllerWithIdentifier: @ "storyboardId" method to obtain the ViewController object of the storyboard.

4. You can also use alloc init to create a controller object and set it as the root controller to display the page, but you must use code to add the control.

5. storyboard needs to be automatically loaded. Even if the storyboard is set to MyViewController, If you create a ViewController through alloc init instead of loading the storyboard, the storyboard (including the control) will not be automatically loaded.

6. for reference, if MyViewController implements the loadView method, it will execute the method in loadView instead of loading the storyboard or xib file (before loading the file). If not, search for the storyboard or the xib corresponding to the nibName. If the nibName cannot be found, the system will first find the xib file with the same name as the Controller class name after the Controller is removed, if not, find the xib file with the same name as the controller class.

7. when calling [self. window makeKeyAndVisible] When the method is used, the window will be displayed, the root controller of the window will be called, and the view of the root controller will be called, because it is a lazy load, if myvc is set before. view attributes, the view will be drawn immediately. After the View is successfully drawn, the viewDidLoad method will be called (this process will only be called once ). The other image may be clearer, but xib is ignored.

8. You can use the pushViewController method of UINavigationController to redirect the interface, and the push is first displayed. (Stack is used to display the View on the top of the stack by releasing the stack and destroying the controller and View on the top of the stack)

9. Add sub-controls to NavigationContoller in four ways:

10. Stack Entry and Exit Methods

1 // use the push method to allow a controller to stack 2-(void) pushViewController :( UIViewController *) viewController animated :( BOOL) animated; 3 4 // use the pop method to exit the stack 5 6 // remove the Controller on the top of the stack 7-(UIViewController *) popViewControllerAnimated :( BOOL) animated; 8 9 // return to the specified sub-controller 10-(NSArray *) popToViewController :( UIViewController *) viewController animated :( BOOL) animated; 11 12 // return to the root controller (stack bottom Controller) 13-(NSArray *) popToRootViewControllerAnimated :( BOOL) animated;Stack entry and exit

11. the return button of the navigationBar of the ViewController on the top of the stack is determined by the backBarButtonItem in the ViewController on the top of the stack. You only need to assign UIBarButtonItem values to the BackBarButtonItem at the top of the stack to modify the title of the Return key.

12. By default, the Controller's View is full of the entire screen.

13. You can set the root controller by dragging the rootViewController attribute of navigationController.

14. storyboard: Drag NavigationCotroller directly, connect to ViewController by means of drag-and-drop connection, and select push for seue. (You can still select push in IOS7, but in ios8. xcode6.1.1, push is not recommended. A new method named show can be used instead, I do not know any advantages for the moment)

15. How to observe the lifecycle of the controller:

16. lifecycle reference diagram:

17. Memory warning processing reference diagram:

 

 

A few days later, I just wrote a record of what I learned every day, which is messy. I hope I can correct it if I have any mistakes.

/! -- Gray indicates future studies. --/

 

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.