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");

    //执行程序

    }


    }

  • 相关阅读:
    谈谈图片上传及canvas压缩的流程
    前端应该懂得初级Web分析指标
    java OPENCV 连通域, Imgproc.findContours 例子,参数说明
    [学习opencv]高斯、中值、均值、双边滤波
    Opencv 图像叠加 添加水印
    帧间提取水印
    opencv mat 转灰度图
    编写一条sql命令,sql删除没有中文的表
    使用JavaCV/OpenCV抓取并存储摄像头图像
    周掌柜
  • 原文地址:https://www.cnblogs.com/jinjiantong/p/3013716.html
Copyright © 2011-2022 走看看