Ios 在特定的时间段后,我如何才能回家

Ios 在特定的时间段后,我如何才能回家,ios,session,timestamp,Ios,Session,Timestamp,我想实现超时功能,如windows会话过期。 我的情况是,如果我没有在30分钟内触摸屏幕,我需要重定向登录屏幕,其他明智的正常将需要工作 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(applicationDidTimeout:)name:10 object:nil]; 然后实施这个方法, -(void)applicationDidTimeout:(NSNotif

我想实现超时功能,如windows会话过期。 我的情况是,如果我没有在30分钟内触摸屏幕,我需要重定向登录屏幕,其他明智的正常将需要工作

  [[NSNotificationCenter defaultCenter]addObserver:self  
           selector:@selector(applicationDidTimeout:)name:10 object:nil];
然后实施这个方法,

 -(void)applicationDidTimeout:(NSNotification*)notif
 {
      NSLog(@"10 mints looping");

     //calling login screen.

 }
但是如果我在视图中工作,时间也会过期。如何避免这种情况。请任何人建议我实现这一点

很抱歉英文和文字结构不好。

试试这个

实现UIApplication的一个子类,以监视应用程序中的所有触摸 应用程序

并在该类中实现以下代码

- (void)sendEvent:(UIEvent *)event {

   if (event) {

       [super sendEvent:event];
       NSSet *allTouches = [event allTouches];
       if ([allTouches count] > 0) {

           UITouchPhase phase = ((UITouch *)[allTouches anyObject]).phase;
           if (phase == UITouchPhaseBegan){

               [self resetIdleTimer];
           }
       }
   }
}
更多详情:

-(void)sendEvent:(UIEvent*)事件

  • 参数

    事件:一个UIEvent对象,它封装了有关事件的信息,包括涉及的触摸

  • 讨论

    子类可以重写此方法以拦截 传入事件。任何截获的事件都应该由 检查拦截的事件后调用[super sendEvent:event]

-(void)resetIdleTimer
是一种可以安排计时器的方法


继续……)

谢谢你的帮助..我可以知道[超级发送事件:事件];和[自复位IDletimer];实施。这对我很有帮助。很酷。非常感谢。