[Navigation Controller Summary-Navigation Controller Stack Objective-C Language]

1. Summary of navigation controller

1. Let’s continue with the content of the previous lesson

notify

Where did we talk about the last lesson? Is it a summary of this navigation controller?

Then, the precautions for using

2. Precautions for using navigation controller:

1) The first point is to use the navigation controller. When you create it, you need to assign it a root controller.

When creating a navigation controller, specify its root controller

notify

2) The second point: When we display other controllers, how do we display it? Is it displayed in the form of push? But when you push, can you push directly?

When displaying the next controller, what do the steps look like?

a. First of all, the first step is to create a controller to be displayed, right?

Create a controller to push to

notify

b. Then, after creating the controller, can you push it?

Then, when pushing, you need to get the navigation controller of the current controller.

After obtaining its controller, you can push it.

notify

When pushing, you need to obtain the navigation controller of the current controller to perform the push operation.

3) Then, this is our push, and when returning,

return:

When returning, I just showed you the two situations, right?

a. First, the first one is to return to the previous controller: popViewControllerAnimated

notify

When this pops up, do I also need to specify its controller?

This is unnecessary. When it returns, it will directly help you return to the previous controller.

Then, I will explain to you later why, it can return to the previous controller,

b. Return to the root controller: popToRootViewControllerAnimated

notify
notify

c. In fact, there is a third situation, which is called returning to the specified controller.

Let me write it out first. Later, I will explain to you why you can return to the specified controller. Then, the method is called

[self.navigationController popToViewController……

notify

[self.navigationController popToViewController:(UIViewController *) animated:(BOOL)];

notify

Do you see it,

notify

You can specify,

If you don't specify, there are two cases, either to the root controller or to the previous controller.

But if you want to go to a certain controller in the middle, can you specify it?

Well, I’ll explain it to you later,

Bring it over first, command + C, command + V,

notify

command + V,

notify

Okay, that's it, return to the specified controller,

notify

Okay, next, we will introduce a more important concept about our navigation controller.

2. Navigation controller stack

1.Have you ever heard of “stack”? You’ve heard of it, right?

That's great, then it's not difficult to understand, what is a "stack"?

Stack: It’s a data structure, right?

Here is the stack of navigation controllers

Navigation controller stack:

notify

Let me tell you what this stack is for.

It helps us manage these controllers. You push one and put it on the stack.

You push one over and put it in the stack.

What about when you pop? If you pop, you will be kicked out. If you pop, you will be kicked out.

Understand, I’m just describing it to you now,

2. Demonstrate to everyone

notify

Now, I jump to the green controller, come in,

notify

1) I jump to the green controller, come in, and it will push one in for you,

2) What about you? Jump to blue again and press another one for you.

Guess you like

Origin blog.csdn.net/madoca/article/details/134706359