屏幕上的按钮很少。我需要计算按下任何 ui 元素时的执行时间,但不将其添加到每个按钮。我的功能只能捕捉 View Controller 的触摸。
- (void)touchesBeganNSSet *)touches withEventUIEvent *)event
{
NSString * strLoad = @"";
for (int i = 1; i <=100000; i++) {
strLoad = [strLoad stringByAppendingString"add"];
}
NSLog(@"touchesBegan");
NSTimeInterval delta = ([[NSProcessInfo processInfo] systemUptime] - [(UIEvent*)event timestamp]);
NSLog(@"time %.2f", delta);
}
- (void)viewDidLoad {
[super viewDidLoad];
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (IBAction)btnMetadataid)sender {
NSString * strLoad = @"aBC";
for (int i = 1; i <=500; i++) {
strLoad = [strLoad stringByAppendingString"add"];
}
}
- (IBAction)btnGenerateCrashid)sender {
NSString * strLoad = @"aBC";
for (int i = 1; i <=5000; i++) {
strLoad = [strLoad stringByAppendingString"add"];
}
}
你好,你需要像这个黑客的方法一样工作:
http://cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html
还有一些这样的:
https://github.com/kennytm/iphone-private-frameworks
这不是很简单,但有可能。 祝你好运!
UDP 类似问题
How to send a touch event to iPhone OS?
关于ios - Hook 任何事件并计算执行时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34988363/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) | Powered by Discuz! X3.4 |