UI Basics: Uinavigationcontroller, interface communication

Source: Internet
Author: User

Uinavigationcontrolle

Uinavigationcontroller: Navigation controller, one of the most commonly used multi-view controllers in iOS, is used to manage multiple view controllers. Also known as a multi-view controller.

The navigation controller can be considered as the controller of the management controller, which mainly manages the controller with hierarchical relationship.

Create:

Uinavigationcontroller inherits from the Uiviewcontroller, manages the control view controller in the form of the stack, must have at least 1 managed view Controller, this controller we call, the navigation controller's root view controller. Any class that inherits from Uiviewcontroller (polymorphic) can be used as the root controller.

Working principle:

The Uinavigationcontroller manages the switch of the controller through the stack, controls the stack and the stack to show the various view controllers.

Uinavigationcontroller's Contentview always shows the view of the top controller. The Viewcontrollers property stores all managed controllers in the stack

The Navigationcontroller property, the attributes in the parent class, and each controller in the stack, can pass this property to get the Uinavigationcontroller object that you are in.

into the stack and out of the stack

pushviewcontroller:animated//Enter the following view controller

Popviewcontrolleranimated://Return to previous view controller

poptoviewcontroller:animated//Return to the specified view controller

poptorootviewcontrolleranimated//Return to the root view controller

Uinavigationcontrolle Common Properties:

Viewcontrollers//All controllers in the stack

Topviewcontroller//Controller at the top of the stack

Visibleviewcontroller//Controller currently being displayed

Navigationbar//navigation bar

Custom Uinavigationbar

navigationbar-navigation Bar, iOS7 after the default is transparent, iOS7 before the default is opaque.

Navigationbar in the case of transparency, a portion of the area is coincident with the Contentview. Navigationbar in the case of opacity, Contentview follows Navigationbar.

Navigationbar Vertical screen under the default height of 44, horizontal screen under the default height of 32.

Custom Navigationbar

Bartintcolor//Set the color of the navigation bar

Setbackgroundimage:forbarmetrics://navigation bar plus background image

Management Uinavigationitem

Uinavigationbar manages a set of Uinavigationitem in addition to defining its own style.

Similar to Uinavigationcontroller, Uinavigationbar also manages a set of Uinavigationitem in the form of stacks. Provides push and pop operations item.

Each view controller has a Navigationitem property. The left button, right button, caption, etc. set in Navigationitem will be displayed on the Navigationbar as the controller is displayed.

Uinavigationitem

Uinavigationitem belongs to M in MVC. Encapsulates the data to be displayed on the Uinavigationbar.

Title//Caption

Titleview//Title View

Leftbarbuttonitem//Left button

Rightbarbuttonitem//Right button

Uibarbuttonitem

Uibarbuttonitem belongs to the MVC m. Defines the trigger event, appearance, etc. of the button on the Uinavigationitem

-initwithbarbuttonsystemitem:target:action:

-initwithtitle:style:target:action:

-initwithimage:style:target:action:

Tintcolor

Inter-Interface Transfer value

Property pass-through value

Proxy pass-through value

Uinavigationcontroller manages the view controller in the form of a stack.

Uinavigationbar manages a set of uinavigationitem,uinavigationitem containing uibarbuttonitem through push and pop control jumps.

Using attribute pass-through values to solve the problem of previous value passing

Using delegate to solve the problem of passing values from backward to forward

UI Basics: Uinavigationcontroller, interface communication

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.