开发者

Touch up outside location from UI Button

I am trying to write a method that receives the coordinates of a ending touch event when a user touches a button and then drags off off the button. Is the touch coordinate information available if the button is passed into the method as the sender? Any suggestions ar开发者_JAVA百科e welcome.


The touch coordinates information is not available form the sender. But your action's selector can take the form

-(IBAction)dragOutside:(id)sender withEvent:(UIEvent*)event;

and the event does contain the coordinates and other things.


You will not get the coordinate information in the sender function of UIButton. you could use to detect touch events by implementing the UIResponder functions.

– touchesBegan:withEvent:
– touchesEnded:withEvent:
– touchesCancelled:withEvent:
- touchesEnded:withEvent:

Have a look SO post

How do you recognize drag gestures

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜