Uiresponder about IOS Event handling

Source: Internet
Author: User

    • A variety of events occur during the user's use of the app
    • Events in iOS can be divided into 3 major types: Touch events, accelerometer events, remote control events
    • Not all objects in iOS can handle events, only objects that inherit Uiresponder can receive and handle events. We call it "responder object."
    • UIApplication, Uiviewcontroller, and UIView inherit from Uiresponder, so they are both responder objects that can receive and handle events

//when the finger starts to touch the view//Nsarray, dictionary, Nsset (unordered)- (void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event{NSLog (@"%ld", Touches.count); NSLog (@"%s", __func__);}//when the finger moves on the view- (void) touchesmoved: (Nsset *) touches withevent: (Uievent *)Event{NSLog (@"%s", __func__); //Get Uitouch ObjectUitouch *touch =[touches anyobject]; //gets the current pointCgpoint curp =[Touch locationinview:self]; //Get previous pointCgpoint PreP =[Touch previouslocationinview:self]; //get x-axis offsetCGFloat OffsetX = curp.x-prep.x; //Get y-axis offsetCGFloat OffsetY = curp.y-prep.y; //Modify the view's location (Frame,center,transform)Self.transform =cgaffinetransformtranslate (Self.transform, OffsetX, OffsetY); //self.transform = cgaffinetransformmaketranslation (OffsetX, 0);    }//when the finger leaves the view- (void) touchesended: (Nsset *) touches withevent: (Uievent *)Event{NSLog (@"%s", __func__);}//called when a touch event is interrupted (call-in)- (void) touchescancelled: (Nsset *) touches withevent: (Uievent *)Event{NSLog (@"%s", __func__);}

Uiresponder about IOS Event handling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.