[英]iOS black screen when bringing app to foreground after some time in background
[英]Reset iOS app in background after some time
我正在尝试重置我的iOS应用程序的状态,当它在后台(例如)30秒后变为活动状态。
我知道设置Application does not run in background mode
和UIApplicationExitsOnSuspend
在plist中,但这会立即重置应用程序的状态而不是一段时间后。 有没有办法在应用程序在后台运行一段时间后触发此操作?
在AppDelegate applicationDidEnterBackground中:当app进入后台时将调用。 你在这里保存enterBackGroundTime
- (void)applicationDidEnterBackground:(UIApplication *)application;
当它进入前台applicationWillEnterForeground:
如果应用程序在后台到前台)或- (BOOL)application:didFinishLaunchingWithOptions:
如果app被杀死并再次启动)将调用。 你在这里得到enterForeGroundTime
- (void)applicationWillEnterForeground:(UIApplication *)application;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
你计算enterBackGroundTime和enterForeGroundTime之间的差异来获得它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.