如何处理iOS上的时间事件? [英] How to handle time events on iOS?

查看:183
本文介绍了如何处理iOS上的时间事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个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上的时间事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆