在我的应用程序中,我想设置不活动超时(IdleTime)。
我该如何设置?
有什么办法可以监控myappdelegate中的所有事件吗?
例如,我有两个 UIViewController 类。
当我点击 UIViewController1
或 UIViewController2
中的一个控件时,它应该由 myappdelegate 监视
最佳答案
要监视应用程序中的所有用户交互事件,您可以使用 UIWindow 子类。在其中实现 sendEvent:
方法:
- (void)sendEvent:(UIEvent*)event {
[super sendEvent:event];
// Process event or just reset inactivity time
}
要在您的应用程序中使用它,您需要打开应用程序主 xib(例如 MainWindow.xib)并在那里设置 UIWindow 实例的自定义类型。
关于iphone - 如何在 iPhone 中捕获应用程序不活动时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3821369/