[Manually create UIWindow Objective-C language]

1. In the last class, we talked about lazy loading of controller View:

notify

1. When will this lazy loading be called? Use us directly, controller self.view

When self.view:

notify

When, call it self.view,

We need to load the controller's view.

self.view loads the view of the controller

notify

We have demonstrated this to everyone, and everyone is already clear about this. We have told you a detail, which is the issue of color, right?

Let me explain the color issue again.

notify

Here we are, hmVc "dot" view "dot" backgroundColor:

notify

What is the order of execution of this?

First of all, does hmVc's "point" view require the controller's view?

At this time, let’s not talk about the color. The color has not arrived yet.

You load the view first, then the color last.

So, let’s look at the view first.

view, how to load it?

First go to the controller:

notify

loadView:

Load the view,

Then, viewDidLoad, the view is truly available.

After you have it, you change its color inside, to green, right?

Here, a color is assigned,

notify

Here, a color is assigned, and then, back to the Delegate,

notify

Now, is this view considered real?

At this time, I gave it another color, red.

Changed it to red,

So it finally displays in red,

But, when we debug through breakpoints:

notify

Also add a breakpoint at the bottom:

notify

Also add a breakpoint in the controller:

notify

command + R:

notify

Take one:

notify

1) Create a controller

2) Set the view's color to red,

notify

hmVc "dian" view, when encountering this "dian", enter the controller:

3) In the controller, execute loadView:

notify

Is the view loaded now?

4) Then, in viewDidLoad::

notify

At this time, if I jump again, it will no longer stay on this line:

notify

I won’t stay in this business anymore.

Then this background color, once assigned,

It's equivalent to passing directly.

Look, as soon as you leave, it reaches line 31:

notify

Isn’t that right? We went directly to line 31.

So, some students may have questions about this color.

Let me explain it clearly to everyone,

Okay, this is our lazy loading of the view of this controller.

Guess you like

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