1 创建一个类继承 UIApplication
.h 文件:
#include <CommonCrypto/CommonCrypto.h>
增加属性: @property(nonatomic,assign) BOOL isMoved;
.m 文件
- (void)sendEvent:(UIEvent*)event{
if (event.type==UIEventTypeTouches) {
UITouch*touch = [event.allTouchesanyObject];
if(touch.phase==UITouchPhaseBegan) {
self.isMoved=NO;
}
if(touch.phase==UITouchPhaseMoved) {
self.isMoved=YES;
}
if(touch.phase==UITouchPhaseEnded) {
if(!self.isMoved&& event.allTouches.count==1) {
// UITouch *touch = [event.allTouches anyObject];
if(@available(iOS9.1, *)) {
CGPoint locationPoint = [touch preciseLocationInView:touch.view];
// 拿到点了就可以任你宰割, }
}
self.isMoved=NO;
}
}
[supersendEvent:event];
}
3 main 函数包含刚刚创建的类
修改 main 函数的返回语句 return UIApplicationMain(argc, argv, NSStringFromClass([自定义类 class]), NSStringFromClass([AppDelegate class]));