变更记录

序号 录入时间 录入人 备注
1 2016-04-14 Alfred Jiang -

方案名称

UIEvent - iOS 事件拦截

关键字

UIEvent \ 事件拦截 \ 捕获任意点击事件

需求场景

  1. 需要响应任意点击事件
  2. 需要接收任意交互事件信息

参考链接

  1. 博客园 - iOS事件拦截(实现触摸任意位置隐藏指定view)

详细内容

1. 新建一个自定义的 MyApplication 继承自 UIApplication,在 MyApplication 中实现 -(void)sendEvent:(UIEvent )event* 方法
- (void)sendEvent:(UIEvent*)event 
{
    //接收 event 并发送通知   
    [[NSNotificationCenter defaultCenter] postNotificationName:NotificationMyApplicationSendEvent object:event];
    [super sendEvent:event];
}
2. 修改 main.m 中 int main(int argc, char argv[])* 方法
int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, NSStringFromClass([MyApplication class]), NSStringFromClass([AppDelegate class]));
    }
}

效果图

(无)

备注

(无)

results matching ""

    No results matching ""