1
我想设置一个全局UITouch处理程序来调试所有正在通过系统的UITouch事件以及哪个视图是目标等。我该如何实现这一点?如何跟踪全球UITouches?
我想设置一个全局UITouch处理程序来调试所有正在通过系统的UITouch事件以及哪个视图是目标等。我该如何实现这一点?如何跟踪全球UITouches?
使UIApplication
一个子类覆盖sendEvent:
方法:
@interface MyApplication : UIApplication
@end
@implementation MyApplication
- (void)sendEvent:(UIEvent *)event {
if (event.type == UIEventTypeTouches) {
NSLog(@"Touch event: %@", event);
}
[super sendEvent:event];
}
@end
在main.m
通过这个子类UIApplicationMain
名称:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "MyApplication.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv,
NSStringFromClass([MyApplication class]),
NSStringFromClass([AppDelegate class]));
}
}
我认为这篇文章将帮助DETECTING TAPS AND EVENTS ON UIWEBVIEW – THE RIGHT WAY。您可以使用相同的技术。