Uinavigation,uiview,modalview the relationship between controllers

Source: Internet
Author: User

If the current is a VC, then it is too simple, you can push directly to the next VC
Addshopviewcontroller *controller = [[Addshopviewcontroller alloc] Init];controller.view.backgroundcolor = [ Uicolor whitecolor];//Set the background color to white, eliminating the residual shadow [Self.navigationcontroller Pushviewcontroller:controller Animated:YES];
Sometimes need to pushviewcontroller from modal view, this is certainly not, because you do not have NC, can nslog a try to know.
NSLog (@ "viewcontrollers before pushing:%@", self.navigationController.viewControllers);
At this point you want to add a Viewcontroller view on your self.view, what you have to do is: [self addchildviewcontroller:xxx]; or Addsubview. Because there is no nav, if you want to use the NAV to control the VC, the general is the first nav, and then the VC into NAV, if itself is a VC so direct
Uinavigationcontroller *navcontroller = [[Uinavigationcontroller alloc]initwithrootviewcontroller:self]; [Self Presentviewcontroller:navcontroller animated:yes completion:nil];
So that your modal have an NV, then you can in this modal inside with [Self.navigationcontroller Pushviewcontroller:controller Animated:yes]; The complete one is this way, storyboard is very clear.
Myviewcontroller *myviewcontroller = [Myviewcontroller alloc] init]; Uinavigationcontroller *navcontroller = [Uinavigationcontroller alloc] Initwithrootviewcontroller:myviewcontroller] ;//Presuming a view controller is asking for the modal transition in the first place. [Self Presentviewcontroller:navcontroller animated:yes completion:nil];

Uinavigation,uiview,modalview the relationship between controllers

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.