iPhone会话 - 不活动时超时 [英] iPhone session - timeout on inactivity

查看:89
本文介绍了iPhone会话 - 不活动时超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户成功登录我的应用程序时,会话启动,在X不活动时间后会话将超时。

When the user successfully log into my app, session starts, after X period of inactivity the session will time out.

现在如何检测,用户是看看他是否主动使用该应用程序或不使用它?

Now how do you detect, the user to see if his active using the application or not using it?

1)检查每个按钮?

1) Check every on button?

2)检查屏幕加载?

推荐答案

最优雅我发现这样做的方法是在 UIApplication 上使用一个类别,它提供了一个 sendEvent:方法来重置一个 NSTimer (当然在调用其超类实现之后)。如果计时器熄灭,请发布通知。在您想要对超时作出反应的任何地方收听通知。这样做意味着您无需在整个应用程序中添加代码以在每次交互时重置计时器。

The most elegant way I've found to do this is to use a category on UIApplication that provides a sendEvent: method that resets an NSTimer (after calling its superclass implementation of course). If the timer goes off, post a notification. Listen for the notification everywhere you want to react to the timeout. Doing it this way means that you don't have to add code all through your app to reset the timer on every interaction.

话虽如此,我同意Shaggy Frog ,这不是iOS应用程序的典型行为,因此从HCI角度来看通常不是一个好主意。

Having said that, I agree with Shaggy Frog, this isn't typical behaviour for an iOS application, so it's not usually a good idea from a HCI perspective.

这篇关于iPhone会话 - 不活动时超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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