zoukankan      html  css  js  c++  java
  • iOS-响应上下左右滑动手势

     
     

    -(void)viewDidLoad{

         UISwipeGestureRecognizer *recognizer; 

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

         [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];

         [[self viewaddGestureRecognizer:recognizer];

         [recognizer release];

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

         [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];

          [[self viewaddGestureRecognizer:recognizer];

          [recognizer release];

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

          [recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];

          [[self viewaddGestureRecognizer:recognizer];

          [recognizer release];

         UISwipeGestureRecognizer *recognizer;

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

         [recognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];

         [[self viewaddGestureRecognizer: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");

                    //执行程序

               }


    }

  • 相关阅读:
    vue关于样式的绑定
    vue插口
    vue组件 父子 通讯
    vue实现翻页功能加高阶函数加购物车
    MySQL 索引面试总结
    phpstorm配置git并解决Terminal 中文乱码(Unicode 编码)的方法
    php 下载图片并打包成Zip格式压缩包
    MySQL5.6升级到5.7详细教程
    windows下安装vue教程
    一致性hash算法详解
  • 原文地址:https://www.cnblogs.com/daguo/p/2621923.html
Copyright © 2011-2022 走看看