zoukankan      html  css  js  c++  java
  • gesture Recognizer

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected:)]; 
        
        doubleTap.numberOfTapsRequired = 2
        
        [self.view addGestureRecognizer:doubleTap]; 
        UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchDetected:)]; 
        
        [self.view addGestureRecognizer:pinchRecognizer]; 
        
        UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationDetected:)]; 
        
        [self.view addGestureRecognizer:rotationRecognizer]; 
        
        UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDetected:)]; 
        
        swipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight; 
        
        [self.view addGestureRecognizer:swipeRecognizer]; UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressDetected:)]; 
        
        longPressRecognizer.minimumPressDuration = 3; longPressRecognizer.numberOfTouchesRequired = 1
        
        [self.view addGestureRecognizer:longPressRecognizer];
    }

    - (IBAction)pinchDetected:(UIGestureRecognizer *)sender 

        CGFloat scale = [(UIPinchGestureRecognizer *)sender scale]; 
        CGFloat velocity = [(UIPinchGestureRecognizer *)sender velocity]; 
        NSString *resultString = [[NSString alloc] initWithFormat: @"Pinch - scale = %f, velocity = %f", scale, velocity]; 
        self.statusLabel.text = resultString; 


    - (IBAction)rotationDetected:(UIGestureRecognizer *)sender 

        CGFloat radians = [(UIRotationGestureRecognizer *)sender rotation]; 
        CGFloat velocity = [(UIRotationGestureRecognizer *)sender velocity]; 
        NSString *resultString = [[NSString alloc] initWithFormat: @"Rotation - Radians = %f, velocity = %f", radians, velocity]; 
        self.statusLabel.text = resultString; 
    }
  • 相关阅读:
    EcShop二次开发学习方法
    [ 产品经理 ] 互联网产品经理常用软件及工作平台
    Tengine – Nginx衍生版
    把PHP大牛记下来,方便以后关注
    看了极光推送技术原理的几点思考
    centos磁盘满了,查找大文件并清理
    LNMP一键安装包 PHP自动升级脚本
    微信红包系统设计 & 优化
    程序员每天每周每月每年该做的事
    php中$_REQUEST、$_POST、$_GET的区别和联系小结
  • 原文地址:https://www.cnblogs.com/zyip/p/2662283.html
Copyright © 2011-2022 走看看