IOS code notes on the left and right sliding effect _ios

Source: Internet
Author: User

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.

Related Article

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.