Window, view, View Controller

Source: Internet
Author: User
WindowWindows and views are used to indicate the visual content of an application and the direct interaction between management and users. A window is an instance of the UIWindow class. It is invisible. It is used to hold one or more views. The window overwrites the entire screen. Most iOS apps only have one window. ViewA view is an instance of the UIView class and defines a rectangular area in the application window. The view displays content in its rectangle. It has some attributes that can be changed and can receive a touch event. A view can also have a series of subviews. Many User Interface classes are subclasses of the UIView class. We can combine multiple UI elements in a hierarchy to construct a complex UI. For example:

Image Source: iPhone. and. iPad App.24-Hour. Trainer
MVC Mode
The most common mode for iOS programming is the MVC mode. The MVC pattern requires programmers to think about which type of class is in a different pattern, view, or controller (data, view, or manager. If your class plays one or more of the above three roles, it is not a good design.
Data (model): Used to store and organize data in a certain way. Data availability is the stock price obtained from a website. A user input article is waiting. View class: Displays data to users. Management class(Control class): Manages connections between data and views. The goal of MVC is to differentiate objects as much as possible and to cooperate in the division of labor. To enhance program scalability and flexibility. A class indicates that there should be no code for drawing the stock price. A class that implements a button should not process the input when the user presses the button. IOS basically follows the MVC mode. There are three categories: data, view, and controller. The Controller manages the content and the interaction between users and views. The view shows a complex user interface, such as a button. The Code (in the Controller class) is responsible for the operations (responses) to be performed when the button is pressed ). The most common controller class is UIViewController. The UIViewController class defines many methods called when important events occur. We can override these methods in our controller class so that we can do something when important events occur. Several of the most common methods to be reloaded are:-didReceiveMemoryWarning: viewDidLoad is called when the memory is insufficient: The view is called after it is loaded into the memory. This function is a good place to initialize our own UI elements.
We can easily create a connection between the Controller class and the UI element through xcode Interface Builder.

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.