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]; } 。 |