View Controller in Chapter 6 of iOS

Source: Internet
Author: User

Target

Common View Controllers

View Controller Functions

MVC in iOS

Create a multi-view application

 

1. Common View Controllers

UIViewController

View Controller parent class

Each View Controller has a master view.

 

UINavigationController

Tree hierarchy navigation

A horizontal bar of 44 in height at the top of the page


UITabBarController

With a tab bar

Allows you to manage multiple view controllers.

 


UITabelViewController

Simplified table usage

UIImagePickerController

Select an image and an image selector from the built-in album.

You can navigate to the album level.


 

 

2. View Controller Functions

Function

Manage the display of views and respond to events

Act as the coordinator between the user interface and the Application Data Model

Display

LoadView

ViewDidLoad

ViewWillAppear view to be displayed soon

The viewDidAppear view is displayed.

ViewWillDisappear view to disappear

ViewDidDisappear view disappears

Response direction change

Whether shouldAutorotateToInterfaceOrientation supports Rotation

WillRotateToInterfaceOrientation: duration: What to do before Rotation

WillAnimateRotationToInterfaceOrientation: duration

DidRotateFromInterfaceOrientation: what to do after rotation

Low Memory Processing

Handle System notifications when the memory is insufficient

DidReceiveMemoryWarning

 

3. MVC in iOS

Function division

Model:

Class for saving Application Data

View:

Windows, controls, and other users can see

Components of the elements that can interact with them

Controller:

Bind the model and view together

Determine how to process user input application logic

 

Principles

The Controller can communicate directly with the Model.

The Controller can also directly communicate with the View.


Model and View cannot communicate directly.

The communication between View and Controller in iOS is transparent and fixed.

Mainly implemented through outlet and action

View is responsible for displaying static objects, which is determined by the Controller Interface.

The delegate and dataSource of View are generally Controller


The Controller is responsible for translating and formatting Model data for the View.

The Model distributes data update information by means of notification or callback. The Controller can select to listen to information that is of interest to it.


View can also listen to broadcast information, but it is generally not the information sent by the Model.

A complete App is a collection of many MVC

 

4. Create a multi-view application

Complete a program with two interfaces. Each interface has a button. click the button to switch to another interface.

 

Main Operations

(0) Create an empty ios Project

(1) Create the Root View Controller and nib file-RootViewController

(2) modify the application delegate and start to open RootViewController. xib

(3) Write RootViewController. h and add the <switch> button for event processing.

(4) Modify MainWindow. xib

(5) Write SwitchViewController. m

(6) Implement the content View

 

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.