How to determine if this is a new day in an iOS project?

I have a UIView, I want it to display on a new day. For example, today I launch my application and that UIView is coming to me, but after that I can not see this UIView until tomorrow.

So, I want to know how to judge whether a new day will display a UIView?

+6
source share
1 answer

You need to register to notify UIApplicationSignificantTimeChangeNotification .

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(timeChange) name:UIApplicationSignificantTimeChangeNotification object:nil]; 

Then in the timeChange method (or timeChange you call it) update your view.

Do not forget to unregister:

 [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationSignificantTimeChangeNotification object:nil]; 

This notification is sent at midnight if the user changes the time on his device or changes the time zone. If your application is in the background during a change, it will be notified when the application returns to the foreground.

+15
source

All Articles