zoukankan      html  css  js  c++  java
  • 5分钟App无操作,自动跳转到登录页面

    // 重写UIWindow下面的方法 sendEvent
    - (void)sendEvent:(UIEvent *)event
    {
        [super sendEvent:event];
        
        NSSet *allTouches = [event allTouches];
        if ([allTouches count] > 0) {
    
            // To reduce timer resets only reset the timer on a Began or Ended touch.
            UITouchPhase phase = ((UITouch *)[allTouches anyObject]).phase;
            if (phase == UITouchPhaseBegan || phase == UITouchPhaseEnded) {
                if (!idleTimer) {
                    [self windowActiveNotification];
                } else {
                    [idleTimer invalidate];
                }
                if (idleTimeInterval != 0) {
                    self.idleTimer = [NSTimer scheduledTimerWithTimeInterval:idleTimeInterval 
                                                                      target:self 
                                                                    selector:@selector(windowIdleNotification) 
                                                                    userInfo:nil repeats:NO];
                }
            }
        }
    }
    
    
    - (void)windowIdleNotification
    {
        NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
        [dnc postNotificationName:KSDIdlingWindowIdleNotification 
                           object:self
                         userInfo:nil];
        self.idleTimer = nil;
    }
    
    - (void)windowActiveNotification
    {
        NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
        [dnc postNotificationName:KSDIdlingWindowActiveNotification 
                           object:self
                         userInfo:nil];
    }
  • 相关阅读:
    (五)L-BFGS算法
    (四)BFGS
    (三)DFP算法
    (二)拟牛顿条件
    (一)牛顿法与阻尼牛顿法
    遗传算法求解最优值
    Anaconda(Python3.6)配置OpenCV3.3
    SVM基础知识
    IO流
    webserver服务器优化0.1
  • 原文地址:https://www.cnblogs.com/tomblogblog/p/4533345.html
Copyright © 2011-2022 走看看