zoukankan      html  css  js  c++  java
  • iOS 左右滑动 手势 响应方法

    1.  

    @property (nonatomic, strong) UISwipeGestureRecognizer *leftSwipeGestureRecognizer;

    @property (nonatomic, strong) UISwipeGestureRecognizer *rightSwipeGestureRecognizer;

    2.  

    @synthesize leftSwipeGestureRecognizer,rightSwipeGestureRecognizer;

    3. 在视图控制器里加载这两个手势

       self.leftSwipeGestureRecognizer = [[UISwipeGestureRecognizer allocinitWithTarget:self action:@selector(handleSwipes:)];

       self.rightSwipeGestureRecognizer = [[UISwipeGestureRecognizer allocinitWithTarget:self action:@selector(handleSwipes:)];

       self.leftSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;

       self.rightSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight;

       [self.viewaddGestureRecognizer:self.leftSwipeGestureRecognizer]; 

       [self.viewaddGestureRecognizer:self.rightSwipeGestureRecognizer];

    4. 

    - (void)handleSwipes:(UISwipeGestureRecognizer *)sender

    {

        if (sender.direction == UISwipeGestureRecognizerDirectionLeft) {

        //添加要响应的方法

                }

            if (sender.direction == UISwipeGestureRecognizerDirectionRight) {

        //添加要响应的方法

               }

    }

     

  • 相关阅读:
    Zabbix 3.0编译安装
    用Python发布自己的代码
    欧拉公式为世界上最完美的公式
    通过别人远端安装anaconda来说配置文件
    jupyter安装与使用
    make在latex中的妙用
    latex源码到PDF文件
    anconda配置国内源
    git命令速查
    一张色环图教你搞定配色(转)
  • 原文地址:https://www.cnblogs.com/someonelikeyou/p/3512268.html
Copyright © 2011-2022 走看看