Code screenshots and Touch events common functions (IOS)

Source: Internet
Author: User

The code screenshot is divided into five steps:

first create a view on the view controller

UIView *aview = [[UIView alloc] Initwithframe:cgrectmake (0, 0, +, 568)];
Aview.backgroundcolor = [Uicolor blackcolor]; [Self.view Addsubview:aview]; [Aview release];


1. Set the size of the picture to be snapped Uigraphicsbeginimagecontext (aView.frame.size);

2. for which view fixed size picture [Aview.layer renderincontext:uigraphicsgetcurrentcontext ()];

3. Get the screenshot object UIImage *image = Uigraphicsgetimagefromcurrentimagecontext ();

4. finish drawing the picture

Uigraphicsendimagecontext ();

5. Save to album uiimagewritetosavedphotosalbum (image, nil, nil, nil);



common functions for touch events in the UI
triggered when the finger leaves the screen(Touch End), if you want to implement a method or function at the end of the touch, write it in this function- (void) touchesended: (Nsset*) touches withevent: (uievent*) Event

triggered when the finger touches the screen,if you want to implement a method or function when you touch the screen, write it in this function
- (void) Touchesbegan: (Nsset*) touches withevent: (uievent*) Event

When the touch is canceled(The premise is that the finger must touch the screen), if you want to implement a method or function when the touch screen is canceled, write it in this function- (void) touchescancelled: (Nsset*) touches withevent: (uievent*) Event

triggers when the finger touches the screen and moves within the screen(at this point the finger does not leave the screen), if you want to implement a method or function when the touch screen is moving, write it in this function
- (void) touchesmoved: (Nsset*) touches withevent: (uievent*) Event

Collision Detection(find who responds,from big to small)
uiapplication, UIWindow->uiviewcontroller->of the View controllerView->viewall child views of(Find by Add order)
event response and collision detection sequence reversed(Viewcan receive,Not Responding) uilableuser interaction is turned off by default; UIButtonresponds to user interaction; UIViewcannot respond,Event passing down

Code screenshots and Touch events common functions (IOS)

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.