• [ios] 响应上下左右滑动手势


    -(void)viewDidLoad{

    UISwipeGestureRecognizer *recognizer; 

    recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];

         [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];

        [[selfview] addGestureRecognizer:recognizer];

    [recognizer release];

        recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];

         [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];

        [[selfview] addGestureRecognizer:recognizer];

    [recognizer release];

     recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];

         [recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];

        [[selfview] addGestureRecognizer:recognizer];

    [recognizer release];

     

     UISwipeGestureRecognizer *recognizer;

        recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];

         [recognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];

        [[selfview] addGestureRecognizer:recognizer];

    [recognizer release];



    }

    -(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{

    if(recognizer.direction==UISwipeGestureRecognizerDirectionDown) {

           NSLog(@"swipe down");

    //执行程序

    }

    if(recognizer.direction==UISwipeGestureRecognizerDirectionUp) {

           NSLog(@"swipe up");

    //执行程序

    }


    if(recognizer.direction==UISwipeGestureRecognizerDirectionLeft) {

           NSLog(@"swipe left");

    //执行程序

    }


    if(recognizer.direction==UISwipeGestureRecognizerDirectionRight) {

           NSLog(@"swipe right");

    //执行程序

    }


    }

  • 相关阅读:
    命令行扩展功能
    bash的工作特性及其使用方法
    Linux的管理类命令及其使用方法
    命名规范
    CSS后代选择器可能的错误认识
    两个viewport的故事(第二部分)
    两个viewport的故事(第一部分)
    移动前端开发之viewport的深入理解
    mybatis 详解(五)------动态SQL
    mybatis 详解(四)------properties以及别名定义
  • 原文地址:https://www.cnblogs.com/jinjiantong/p/3013716.html
Copyright © 2020-2023  润新知