zoukankan      html  css  js  c++  java
  • 如何监听app所有事件

    1, 修改main方法

    int main(int argc, char * argv[]) {
        @autoreleasepool {
            return UIApplicationMain(argc, argv, NSStringFromClass([AppDelegate class]), NSStringFromClass([AppDelegate class]));
        }
    }

    2, 让   AppDelegate继承自UIApplication,原来是继承自UIResponder

    @interface AppDelegate : UIApplication <UIApplicationDelegate>

    3, 在AppDelegate中实现   sendEvent方法

    - (void)sendEvent:(UIEvent *)event
    {
        [super sendEvent:event];
        
        NSSet *allTouches = [event allTouches];
        if (allTouches.count > 0) {
            UITouchPhase phase = ((UITouch *)[allTouches anyObject]).phase;
            if (phase == UITouchPhaseBegan) {
                NSLog(@"TouchPhaseBegan");
            }
        }
    }

     

  • 相关阅读:
    JQuery源码解析-Dom加载过程
    多个script标签的作用域
    JQuery源码解析-JQuery的工具方法(1)
    JQuery源码解析-JQuery的工具方法
    JQuery源码解析-JQuery.extend()方法
    JQuery源码解析-添加JQuery的一些方法和属性
    中兴捧月算法精英挑战赛-迪杰斯特拉派
    C语言中的内存相关问题
    动态内存管理
    虚函数与虚继承小结
  • 原文地址:https://www.cnblogs.com/dashengios/p/10595775.html
Copyright © 2011-2022 走看看