Lan Yi Ios/uinavigationcontroller

Source: Internet
Author: User

Today Liu Guobin with learning the navigation bar control, Uinavigationcontroller,uitabbarcontroller, the two controls have a similar place, Uinavigationcontroller can be translated as a navigation controller, Often used in iOS. Uinavigationcontroller is a container for the view controller in iOS programming, and with the stack management viewcontrollers, each push operation adds a view controller to the top of the stack. The top controller of the stack is then removed via pop.
We do it in the project, usually in the controller.
[Self.navigationcontroller Popviewcontrolleranimated:no]; To remove the top controller from the stack.
Suppose there are now subclass objects of Uiviewcontroller, A, B, C, D.
Set the A controller as the root controller
Uinavigationcontroller *myfirstctrl =
[[Uinavigationcontroller alloc] Initwithrootviewcontroller:myfirstctrl];
Self.window.rootViewController = M_firstctrl;
In a controller, the push B controller
[Self.navigationcontroller pushviewcontroller:b Animated:no];
In the B controller, the push C controller
[Self.navigationcontroller pushviewcontroller:b Animated:no];
In the C controller, the push D controller
[Self.navigationcontroller pushviewcontroller:b Animated:no];
At this time the stack of a controller, there are four elements, we believe that in B, C, d do not have a pop operation, at this time, in a controller, the implementation of [Self.navigationcontroller Popviewcontrolleranimated:no]; is to remove the D controller from the stack, rather than removing the a controller itself. Similarly, when executing again, the C controller is removed.
Before, I thought to remove oneself, today with colleague discussion, wrote a demo to verify a bit, only then knew the truth. So, write to share with you, maybe we already know, smell the word has successively, although I may know the late point, but I am still very happy to share out, to not know the friend

-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (Uievent *) Event {

Create a View Controller

Rootviewcontroller *vc0 = [Rootviewcontroller new];

Create a navigation controller and set the root view of the navigation controller (bottom view)

Uinavigationcontroller *navcontroller = [[Uinavigationcontroller alloc] initwithrootviewcontroller:vc0];

Because the current view is not managed by navigation, you cannot use the push method to jump, only use the present method to jump

[Self Presentviewcontroller:navcontroller animated:yes completion:nil];

Self.navigationcontroller Property

If the current view controller is already managed by the navigation controller, this property has a role

This property is not used if the current view controller is not managed by the navigation controller (value nil)

[Self.navigationcontroller Pushviewcontroller:navcontroller Animated:yes];


Lan Yi Ios/uinavigationcontroller

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: 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.