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)