Swipe gesture is also a very important part of the interaction in iOS, swipe up and down, Uiswipegesturerecognizer can easily solve this problem, no difficulty directly look at the code:
Uiswipegesturerecognizer *upswipegesturerecognizer=[[uiswipegesturerecognizer alloc]initWithTarget:self action:@ Selector (swipegesturerecognizer:)]; Upswipegesturerecognizer.direction=uiswipegesturerecognizerdirectionup; [Self.view Addgesturerecognizer:upswipegesturerecognizer]; Uiswipegesturerecognizer *downswipegesturerecognizer=[[uiswipegesturerecognizer alloc]initWithTarget:self Action: @selector (Swipegesturerecognizer:)]; Downswipegesturerecognizer.direction=uiswipegesturerecognizerdirectiondown; [Self.view Addgesturerecognizer:downswipegesturerecognizer]; Uiswipegesturerecognizer *leftswipegesturerecognizer=[[uiswipegesturerecognizer alloc]initWithTarget:self Action: @selector (Swipegesturerecognizer:)]; Leftswipegesturerecognizer.direction=uiswipegesturerecognizerdirectionleft; [Self.view Addgesturerecognizer:leftswipegesturerecognizer]; Uiswipegesturerecognizer *rightswipegesturerecognizer=[[uiswipegesturerecognizer Alloc]iNitwithtarget:self Action: @selector (Swipegesturerecognizer:)]; Rightswipegesturerecognizer.direction=uiswipegesturerecognizerdirectionright; [Self.view Addgesturerecognizer:rightswipegesturerecognizer];
Gesture Processing:
-(void) Swipegesturerecognizer: (Uiswipegesturerecognizer *) recongnizer{ if (recongnizer.direction== Uiswipegesturerecognizerdirectionup) { NSLog (@ "swipe up"); NSLog (@ "blog Park-flyelephant"); } if (recongnizer.direction==uiswipegesturerecognizerdirectiondown) { NSLog (@ "swipe down"); NSLog (@ "Original address: Http://www.cnblogs.com/xiaofeixiang"); } if (recongnizer.direction==uiswipegesturerecognizerdirectionleft) { NSLog (@ "swipe left"); NSLog (@ "iOS technology Group: 228407086"); } if (recongnizer.direction==uiswipegesturerecognizerdirectionright) { NSLog (@ "swipe right");} }
:
iOS Development-uiswipegesturerecognizer swipe gesture