[Load custom controller Objective-C language]
Mobile
2023-12-16 19:22:39
views: null
1. The next operation is more critical.
1. Earlier, we started from UI basics, then to UI advanced, on the first day, and so far,
In all applications and newly created projects, after startup, are the loaded controllers the controller with the arrow in Main.storyboard?
Then, you can also create a new storyboard, and then drag a controller into it,
For example, drag a UITableViewController,
Is it possible to configure it so that it can load this storyboard?
2. Then, what we have to do next is to load your custom controller through code.
This is something you must master,
There's no room for negotiation.
Later, in the process of learning later, we often use,
Then, in your work projects, always write,
Understand,
1) Load custom controller,
2) Then, where is loading a custom controller implemented?
I turned this off,
Create another project:
Create a new project:
Give me a name,
- Load custom controller
Then, click Next, look at the previous serial number, and then come back and add the serial number.
02 - Load custom controller
Just in our code today,
Click Create:
Click on the AppDelegate.m file on the left:
Come and see,
Let's talk about it. Usually, when we operate and load a custom controller,
An action to load a custom controller:
1) Earlier, when introducing this proxy method to you, we said that after the loading is completed, can we perform some custom operations:
Yes, when we load the custom controller, we also load your custom controller here.
As for us earlier, I don’t know if you have ever used a custom controller, no, no, we are going to learn it today,
First of all, I need to explain to you the basic operation process.
Load custom controller:
1) For a basic operation process, if you want to load a custom controller, then you definitely don’t want the ones provided by the system.
Right, so, let’s delete the ViewController “dot” m, “dot” h, and then the storyboard,
1) viewController.h/.m, Main.storyboard, delete
Is this font too big? Let me make it smaller.
Select these words, command + - (command plus minus sign):
This is the first step. After you delete these things, what about the second step?
2) After deleting this, we, by default, do the system require you to have a Main in this configuration file?
In info.plist, Main storyboard file base name: Main,
Is there a Main here?
It will load this by default, but after you delete this Main.storyboard,
That Main will never disappear.
Delete these three,
Move to Trash directly
But if the system provides some framework or something, you don’t want to Move To Trash. That’s very dangerous.
It doesn't matter, but is it still in info.plist?
Therefore, your second step is to delete the storyboard file name loaded by default in the configuration file.
There's no problem with this, right?
I won’t delete it now. I’ll show you its effect first.
Change the simulator to iPhone6S
Don’t delete it yet, let’s take a look at its effect.
Let’s see what fault he will report to us,
command + R
Did it just collapse?
Take a look at why it crashed. You may also encounter this problem when writing.
Terminating
Origin blog.csdn.net/madoca/article/details/134028398