[Application proxy object ApplicationDelegate-Introduction to the application startup process Objective-C language]

1. Let’s continue what we said yesterday.

notify

notify

1. Some people are a little confused about the last part of yesterday’s content. Let’s review it again.

1) When we first started, did we put a button in Main.storyboard?

notify

2) As for me, I want to perform some operations when I click the button, right?

So, I dragged an event to it,

notify

Drag it into the class implementation,

3) So, first of all, step one: what we demonstrate is getting this application object:

notify

Then, get the application object. For example, if it is a singleton, how to verify that it is a singleton?

Have you obtained it twice and printed their addresses? Are they exactly the same, right?

notify

This is our application, a singleton.

Now don't worry about what a singleton is. When it comes to networks and multi-threading, I will explain how to write this singleton.

3) Set the number on the application avatar,

notify

The default is 0, no number, right?

Then if you want to display numbers, just set it directly,

app.applicationIconBadgeNumber = 10 ;

notify

However, there is one thing to note,

After iOS8.0, do you need to register?

Then, app is your current application.

notify

Notification settings that require registered users:

notify

Then, user permission is required, right?

If the user does not allow you to push, can you push? Is it impossible?

You can’t set the avatar number for your application either.

And, this part of the code:

notify

It is only executed once.

I don’t know if you have noticed when writing code,

Will it prompt you next time you run it?

No way,

Yes, this is a reminder only once.

This is also managed by the system for us.

You don't need to worry,

And that is, after you execute this code for the first time:

notify

Just to remind you,

Sometimes the apps we download, such as WeChat or Alipay,

When you use the camera, you will be reminded to allow this app to open the camera.

Then, you click "Allow" and it can open the camera.

What about this one? It only reminds you once. When you use it, it reminds you again.

And if you come again in the future, this reminder operation will not be performed again.

So, what should you do if the user does not allow you to set it?

Then, if he wants to use this function next time, do you have to remind him to turn on this function in the settings?

Yes, just give me a reminder.

This is the number on the set avatar,

4) There is also a network indicator,

notify

Network status indicator,

Do you know where it is?

notify

The chrysanthemum in the upper left corner, right?

5) Then, there is openURL: just understand this,

6) The last one, status bar management:

notify

How to operate status bar management?

By default, this status bar is managed by the controller.

Then some students may ask, why should we give this status bar to the application, right?

Let me explain to you why we need to hand over this status bar to the application.

Well, in our application, we say, a complete application,

It can't have only one interface, right?

There can't be only one controller, right?

Otherwise, there would be nothing I want to talk about today.

So, there are many controllers, do you have to perform an operation in each one:

notify

Suppose that my application has a relatively deep background.

Now, I want to change the status bar to a light color.

Then do you need to write it once in each controller?

If you don't give it to the application, then in each one, write it once,

Then, you have to hand it over to the application. Is it enough to set it up once?

We are just demonstrating a Hidden now.

notify

In fact, it can also set its Style:

notify

Do you see it:

notify

Can you set it to a light color effect?

Press the command key and enter:

notify

UIStatusBarStyle:

notify

Click to enter:

notify

LightContent:

notify

command + C、

return,

notify

command + V:

notify

Are we in the controller earlier, prefersStatusBarStyle?

notify

No problem, right?

Then, you can do all of this at once through the application:

notify

You don’t need to do it manually anymore, just write each controller one by one.

I won’t demonstrate this anymore, I’ll comment it out:

notify

But, for example, in Xcode7.0, you have to hand over the management of the status bar to the application. How do you do it?

Have we added a Key to the info.plist file?

notify

View Controller-based status bar:NO

Where is this Key?

notify

Click the plus sign. Is it at the bottom?

There’s no need to remember, just scroll to the bottom and that’s it.

Right at the bottom,

Then, turn it off and set it to NO.

Is that enough?

notify

The management of this status bar is left to the application.

notify

You must know this,

Okay, what about these?

Guess you like

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