The project has the need to refresh the view or update the data at zero, how to achieve it?

for example, if a button becomes unavailable after it is clicked, it can not be clicked until the next day, so the button can only be clicked once a day, such as check-in, so how to update the status of the button at zero?

Mar.20,2021

I remember dealing with this kind of business logic when I was doing OA before:

1. Complicated approach: first, when entering the interface, call the server interface to obtain the server time (mobile phone time is not trusted), and then initialize the timer according to this time to judge the time difference between this time and 0 o'clock the next day. The timer keeps timing in the interface, and refreshes the interface at the specified time. If you enter the background and return to the front desk, you can refresh the server time. Reinitialize timer

2. Simple way to do this: receive UIApplicationSignificantTimeChangeNotification notifications, which will be notified when a new day arrives or when the carrier time changes, but you don't know if you haven't used it.

Menu