Today, I learned the methods and applications of gestures in iOS programming, and there are many controls in the screen page, some controls can have click events and users interact directly, can execute corresponding methods, such as Textfield,button,uisegmentcontroll, But static Lableuiimageview and so on need to turn on the interactive switch, add the response gesture to realize the interaction.
Liu Guobin to us in detail seven gestures, including click Touches,uipangesturerecognizer drag, Uilongpressgesturerecognizer long press gesture, Uiscreenedgepangesturerecognizer slide and so on.
An event is an object that the system constantly sends to the application when the user's finger strikes the screen and moves on the screen. The system passes an event to a specific path to an object that can be processed. In iOS, a Uitouch object represents a touch, and a Uievent object represents an event. The event object contains all the touch objects that correspond to the current multi-touch sequence, and can also provide touch objects associated with a particular view or window.
A Responder object is an object that can respond to an event and process it.
Uiresponder is the base class for all responder objects, and it defines the programming interface not only for event handling, but also for common responder behavior.
When the gesture begins to move, let the center point of the image move with the touch point
Case uigesturerecognizerstatechanged:
Self.ii.center=[sender LocationInView:self.view];
Break
When the gesture moves to the end, determine if the image is in the set area, and if you add the picture to the area, note that the coordinates of the image from view to Vie are converted.
Case uigesturerecognizerstateended:
if (Cgrectcontainspoint (Self.vie.frame, Self.ii.center)) {
Cgpoint Old=self.ii.center;
Cgpoint New=[self.view Convertpoint:old ToView:self.vie];
[Self.vie ADDSUBVIEW:SELF.II];
Self.ii.center=new;
Add a post-click gesture to a moving picture
UITapGestureRecognizer *tgr=[[uitapgesturerecognizer
Lan Yi iOS Learning seven gestures touches