如何在iphone-sdk中检测空闲用户
在我的应用程序中,如果用户闲置一段时间,我想调用注销功能,如何完成
这个答案对我来说不起作用 iPhone:检测自上次屏幕触摸以来用户不活动/空闲时间 如果我从 UIApplication 子类化我的应用程序委托类并实现
- (void)sendEvent:(UIEvent *)event
它会给我错误,
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.'
我在应用程序中找不到 UIApplication 的其他实例,
到目前为止
而不是
@interface IdleAppDelegate : NSObject <UIApplicationDelegate> {
我已将其更改为
@interface IdleAppDelegate : UIApplication<UIApplicationDelegate> {
and in main 而不是
int retVal = UIApplicationMain(argc, argv, nil, nil);
我已更改还有
int retVal = UIApplicationMain(argc, argv, @"IdleAppDelegate", @"IdleAppDelegate");
什么事情要做吗?
我收到上述错误...我错过了什么吗...?
请帮忙
谢谢
In my Application I want to call Logout Function if user is idle for certain amount of time how to accomplish
this answer doesn't work for me
iPhone: Detecting user inactivity/idle time since last screen touch
if i subclass my app delegate class from UIApplication and implement
- (void)sendEvent:(UIEvent *)event
It gives me error
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.'
I can't find the other instance of UIApplication in my application
so far i have done
instead of
@interface IdleAppDelegate : NSObject <UIApplicationDelegate> {
I have changed it to
@interface IdleAppDelegate : UIApplication<UIApplicationDelegate> {
and in the main instead of
int retVal = UIApplicationMain(argc, argv, nil, nil);
I've changed it to
int retVal = UIApplicationMain(argc, argv, @"IdleAppDelegate", @"IdleAppDelegate");
Is there anything remaining to do?
I'm getting the above error... am I missing something...?
Please Help
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的应用程序类也是一个应用程序委托类 - 这很糟糕。
UIApplicationMain()
将创建自定义应用程序子类的实例,然后该子类将尝试其委托的实例 - 这也是自定义应用程序子类的实例。您应该将这些问题分开 - 是的,您的自定义应用程序子类需要子类化UIApplication
,但您的应用程序委托应该是一个单独的类,它是NSObject
子类化。Your application class is also an application delegate class - that's bad.
UIApplicationMain()
will create an instance of your custom application subclass, which will then try to an instance of its delegate - which is also an instance of your custom application subclass. You should separate these concerns - yes your custom app subclass needs to subclassUIApplication
, but your app delegate should be a separate class that subclassesNSObject
.试试这个
Try this out