屏幕上有几个按钮。我需要计算按下任何ui元素时的执行时间,但不要将其添加到每个按钮。我的功能仅捕获View Controller触摸。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)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)btnMetadata:(id)sender {
NSString * strLoad = @"aBC";
for (int i = 1; i <=500; i++) {
strLoad = [strLoad stringByAppendingString:@"add"];
}
}
- (IBAction)btnGenerateCrash:(id)sender {
NSString * strLoad = @"aBC";
for (int i = 1; i <=5000; i++) {
strLoad = [strLoad stringByAppendingString:@"add"];
}
}
答案 0 :(得分:1)
嗨,你需要像这个黑客的方法一样工作:
http://cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html
有些像这样:
https://github.com/kennytm/iphone-private-frameworks
这不是很简单,但有可能。 祝你好运!
UDP类似问题