问题描述
我正在编写一个iPad应用程序,当天更改为星期日时,我必须更改图形。我的直截了当的解决方案是检查 - (void)applicationDidBecomeActive:(UIApplication *)应用程序
或 - (void)viewWillAppear:(BOOL)动画
方法,并设置一个计时器,每10分钟一次,以检查应用程序是否活动时,星期日是否已更改。 p>
还有另一种,也许更有效的方式来处理这个问题?
在您的应用委托中,实现以下方法:
- (void)applicationSignificantTimeChange:(UIApplication *)应用程序
当日变化时,或者由于任何原因(例如时区更改),设备的时间已经在后台更改,此方法被调用。
I'm coding an iPad app, and I have to change a graphic when the day changes to Sunday.
My straightforward solution is to check the day in the - (void)applicationDidBecomeActive:(UIApplication *)application
or -(void)viewWillAppear:(BOOL)animated
methods, and set a timer like every 10 mins to check if the day have changed to Sunday while the app is active.
Is there another, perhaps more efficient, way to handle this?
In your appliciation delegate, implement the following method:-(void)applicationSignificantTimeChange:(UIApplication *)application
This method is called when the day changes, or if the device's time has been changed in the background for whatever reason (such as changes to time zone).
这篇关于如何处理iOS上的时间事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!