ios - Hook 任何事件并计算执行时间
<p><p>屏幕上的按钮很少。我需要计算按下任何 ui 元素时的执行时间,但不将其添加到每个按钮。我的功能只能捕捉 View Controller 的触摸。</p>
<pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSString * strLoad = @"";
for (int i = 1; i <=100000; i++) {
strLoad = ;
}
NSLog(@"touchesBegan");
NSTimeInterval delta = ([ systemUptime] - [(UIEvent*)event timestamp]);
NSLog(@"time %.2f", delta);
}
- (void)viewDidLoad {
;
- (void)didReceiveMemoryWarning {
;
}
- (IBAction)btnMetadata:(id)sender {
NSString * strLoad = @"aBC";
for (int i = 1; i <=500; i++) {
strLoad = ;
}
}
- (IBAction)btnGenerateCrash:(id)sender {
NSString * strLoad = @"aBC";
for (int i = 1; i <=5000; i++) {
strLoad = ;
}
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你好,你需要像这个黑客的方法一样工作:</p>
<p> <a href="http://cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html" rel="noreferrer noopener nofollow">http://cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html</a> </p>
<p>还有一些这样的:</p>
<p> <a href="https://github.com/kennytm/iphone-private-frameworks" rel="noreferrer noopener nofollow">https://github.com/kennytm/iphone-private-frameworks</a> </p>
<p>这不是很简单,但有可能。
祝你好运!</p>
<p><strong>UDP 类似问题</strong></p>
<p> <a href="https://stackoverflow.com/questions/4137205/simulate-touch-on-iphone" rel="noreferrer noopener nofollow">Simulate touch on iphone</a> </p>
<p> <a href="https://stackoverflow.com/questions/1746452/how-to-send-a-touch-event-to-iphone-os" rel="noreferrer noopener nofollow">How to send a touch event to iPhone OS?</a> </p></p>
<p style="font-size: 20px;">关于ios -Hook 任何事件并计算执行时间,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/34988363/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/34988363/
</a>
</p>
页:
[1]