From:
http://blog.163.com/cz_jdton/blog/static/92732504201282543017312/
Uicontroleventtouchdown
Single Touch Press event: The user touches the screen, or when a new finger falls.
uicontroleventtouchdownrepeat
Multi-point Touch press event, point touch count is greater than 1: when the user presses the second to third or fourth finger.
Uicontroleventtouchdraginside
When a touch is dragged inside the control window.
Uicontroleventtouchdragoutside
When a touch is dragged outside the control window.
Uicontroleventtouchdragenter
When a touch is dragged from outside the control window to the interior.
Uicontroleventtouchdragexit
When a touch is dragged from inside the control window to the outside.
UIControlEventTouchUpInside
All touches lift events within the control.
Uicontroleventtouchupoutside
all the touch-lift events outside the control (the point-touch must start with the inside of the control to send a notification).
Uicontroleventtouchcancel
All touch cancellation events, that is, a touch is canceled because it is put on too many fingers, or locked or interrupted by a phone call.
Uicontroleventtouchchanged
Sends a notification when the value of the control has changed. Used for sliders, segmented controls, and other value-taking controls. You can configure when a slider control sends a notification, sends it when the slider is dropped, or sends it when it is dragged.
Uicontroleventeditingdidbegin
Sends a notification when editing begins in a text control.
Uicontroleventeditingchanged
Sends a notification when text in a text control is changed.
Uicontroleventeditingdidend
sends a notification when editing ends in a text control.
Uicontroleventeditingdidonexit
Sends a notification when a text control ends editing by pressing the ENTER key (or equivalent behavior).
Uicontroleventalltouchevents
Notifies all touch events.
Uicontroleventalleditingevents
Notifies all events about text editing.
Uicontroleventallevents
Notifies all events.
Instance:
UIButton *btn = [UIButton buttonwithtype:uibuttontypecustom];
Btn.frame = Rect_screen;
Btn.frame = CGRectMake (frame.size.width-20.0f-30.0f, frame.size.height-50.0f, 30.0f, 50.0f);
Btn.backgroundcolor = [Uicolor Bluecolor];
Uicontroleventtouchdraginside
Uicontroleventtouchdragoutside
[Btn addtarget:self Action: @selector (Draginside) forcontrolevents:uicontroleventtouchdraginside];
[Btn addtarget:self Action: @selector (Dragoutside) forcontrolevents:uicontroleventtouchdragoutside];
Dismissview
[Btn addtarget:self Action: @selector (Upinside) forcontrolevents:uicontroleventtouchupinside];
[Self addsubview:btn];
return self;
}
-(void) draginside
{
NSLog (@ "Draginside ...");
}
-(void) dragoutside
{
NSLog (@ "Dragoutside ...");
}
-(void) upinside
{
NSLog (@ "Upinside ...");
}
Long press Event
UIButton *abtn=[uibutton Buttonwithtype:uibuttontypecustom];
[Abtn Setframe:cgrectmake (40, 100, 60, 60)];
[Abtn setbackgroundimage:[uiimage imagenamed:@ "111.png"]forstate:uicontrolstatenormal];
button click event
[Abtn addtarget:self Action: @selector (Btnshort:) forcontrolevents:uicontroleventtouchupinside];
Button length by event
Uilongpressgesturerecognizer *longpress = [[Uilongpressgesturerecognizer alloc] Initwithtarget:selfaction: @selector (Btnlong:)];
Longpress.minimumpressduration = 0.8; Define the time that is pressed
[Abtn addgesturerecognizer:longpress];
-(void) Btnlong: (uilongpressgesturerecognizer*) gesturerecognizer{
if ([gesturerecognizer state] = = Uigesturerecognizerstatebegan) {
NSLog (@ "Long press event");
Uialertview *alert=[[uialertview alloc]initwithtitle:@ "message" message:@ OK to delete this mode. "delegate:selfcancelbuttontitle:@" Cancel "otherbuttontitles:@" delete ", nil];
[Alert show];
}
}