zoukankan      html  css  js  c++  java
  • [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");

    //执行程序

    }


    }

  • 相关阅读:
    python中join函数
    python实现反转字符串
    map函数
    python中lambda函数
    python中reduce函数
    python实现斐波那契数列
    迭代器和生成器
    经典算法动态图
    数据中心团队对于液体冷却的应用还需要适应
    物联网正将数据中心推向边缘
  • 原文地址:https://www.cnblogs.com/jinjiantong/p/3013716.html
Copyright © 2011-2022 走看看