There is such a requirement in the implementation of your project. In general, our navigation bar Back button, is the last page to jump over, click the Back button to return to the interface. But some of the actual needs are not so simple. Some interface returns are only determined by the interface. So when I was in the implementation of the time because of the lack of understanding of the mechanism of the jump, resulting in impossible. Later, in the Boss, Lugo (Daniel) understand. First, we need to know that the navigation bar jumps through the form of a stack. So each time we jump, we will have an extra interface object in the stack. The number in the stack increases, and when we need to go back to one of the previous interfaces, we need to look for this interface in the stack. We need an array to hold the information, and when we find the interface, we can jump through the navigation. The following is the implementation of the Code, in fact, very simple. (Our return button needs to be redefined, this is the click Method after the definition)
-(void) backaction{
Uinavigationcontroller *NAVVC = Self.navigationcontroller;
Nsmutablearray *viewcontrollers = [[Nsmutablearray alloc] init];
For (Uiviewcontroller *VC in [NAVVC Viewcontrollers]) {
[Viewcontrollers ADDOBJECT:VC];
if ([VC ISKINDOFCLASS:[MYNEEDJUMPVC Class]]) {
Break
}
}
[NAVVC setviewcontrollers:viewcontrollers Animated:yes];
}?
? Self.navigationcontroller is the current page;
MYNEEDJUMPVC is the page we need to jump to;
It's that simple. Of course, you can also use the number of navigation bar stack to jump, but you need to know the destination page in the number of stacks is a few, this implementation is a bit complex, but also I started the method, and then use the above method to achieve minutes to get it done! Ha ha! What do not understand can give me a message.
iOS navigation bar returns to the specified page