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; 
    }
  • 相关阅读:
    pat 1027. Colors in Mars (20)
    pat 1035. Password (20)
    pat 1006. Sign In and Sign Out (25)
    pat 1031. Hello World for U (20)
    pat 1005. Spell It Right (20)
    pat 1002. A+B for Polynomials (25)
    pat 1008. Elevator (20)
    pat 1001. A+B Format (20)
    算法分析与设计实验四 密码算法
    Android通讯录管理(获取联系人、通话记录、短信消息)
  • 原文地址:https://www.cnblogs.com/zyip/p/2662283.html
Copyright © 2011-2022 走看看