The example of this article for everyone to share the implementation of iOS sliding operation code for everyone to refer to, the specific content as follows
One, the effect chart
Second, the Code
ROOTVIEWCONTROLLER.M
-(void) viewdidload {[Super viewdidload];
Do no additional setup after loading the view.
self.title=@ "can slide to the left (right)";
Slide Uiswipegesturerecognizer to the right *recognizerleft;
Recognizerleft = [[Uiswipegesturerecognizer alloc] initwithtarget:self action: @selector (Handleswipefromleft:)];
[Recognizerleft setdirection: (Uiswipegesturerecognizerdirectionleft)];
[Self.view Addgesturerecognizer:recognizerleft];
Slide Uiswipegesturerecognizer to the left *recognizerright;
Recognizerright = [[Uiswipegesturerecognizer alloc] initwithtarget:self action: @selector (handleswipefromright:)];
[Recognizerright setdirection: (uiswipegesturerecognizerdirectionright)];
[Self.view Addgesturerecognizer:recognizerright]; #pragma-mark-gesture sliding//left sliding-(void) Handleswipefromleft: (Uiswipegesturerecognizer *) recognizer {NSLog (@ "-------into the left hand
Potential sliding posture-------------"); if (recognizer.direction==uiswipegesturerecognizerdirectionleft) {Uialertview *alert=[[uialertview alloc]initWit Htitle:@ "remind" message:@ "go to the left gesture sliding posture" delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK", nil];
[Alert show]; }//Right-(void) Handleswipefromright: (Uiswipegesturerecognizer *) recognizer {NSLog (@)-------move to the right gesture sliding position-----------
--"); if (recognizer.direction==uiswipegesturerecognizerdirectionright) {Uialertview *alert=[[uialertview alloc]initWi
thtitle:@ "reminds" message:@ "to move to the right gesture sliding posture" delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK", nil];
[Alert show];
}
}
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.