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

                    //执行程序

               }


    }

  • 相关阅读:
    HDU_1846 Brave Game(sg函数简化版)
    POJ 3225 Help with Intervals(线段树)
    ZOJ_3501 Roman Order
    HDU_1527 取石子游戏(威佐夫博弈)
    HDU_2112 HDU Today(DIjkstra + map映射)
    HDU_3339 In Action(Dijkstra + DP)
    单链表的实现(课本上的算法)
    haproxy 基于 uri 实现调度
    haproxy 基于 cookie 实现 session 绑定
    [转]ASP.NET 虚拟主机安全漏洞解决方案
  • 原文地址:https://www.cnblogs.com/daguo/p/2621923.html
Copyright © 2011-2022 走看看