开发者

Log UIControl events

开发者 https://www.devze.com 2023-03-05 14:44 出处:网络
Is there a way of logging the UIControl events that are going on when you touch the screen on the iPhone?

Is there a way of logging the UIControl events that are going on when you touch the screen on the iPhone?

Here's an example - I need to show some information when the user touches down on a button but then lifts their finger outside. However this bit of code doesn't seem to w开发者_如何学Pythonork:

    [self.button addTarget:self action:@selector(showInfo) forControlEvents:UIControlEventTouchDown & UIControlEventTouchUpOutside];


 [self.button addTarget:self action:@selector(showInfo) forControlEvents:UIControlEventTouchDown];
 [self.button addTarget:self action:@selector(showInfo) forControlEvents: UIControlEventTouchUpOutside];

Do it like this.

On topic:

You could inherit the UIButton class and override the following methods:

Responding to Touch Events

– touchesBegan:withEvent:

– touchesMoved:withEvent:

– touchesEnded:withEvent:

– touchesCancelled:withEvent:


Try this

[button addTarget:self action:@selector(showInfo:withEvent:) forControlEvents:UIControlEventTouchDragOutside|UIControlEventTouchUpOutside|UIControlEventTouchDragInside|UIControlEventTouchDown];
0

精彩评论

暂无评论...
验证码 换一张
取 消