Wednesday, 6 March 2013

Tap and Swipe Gesture iPhone

Single tap Gesture. 

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doSingleTap)];
    singleTap.numberOfTapsRequired = 1;
    [self.view addGestureRecognizer:singleTap];


- (void)doSingleTap{

}

Swipe Left Gesture and Swipe Right

 UISwipeGestureRecognizer *swipeLeftGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftGesture:)];
    swipeLeftGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
    [self.view addGestureRecognizer:swipeLeftGestureRecognizer];
    // [swipeLeftGestureRecognizer release];
    
    UISwipeGestureRecognizer *swipeRightGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightGesture:)];
    [self.view addGestureRecognizer:swipeRightGestureRecognizer];


- (void)swipeLeftGesture:(UISwipeGestureRecognizer *)sender{
}

- (void)swipeRightGesture:(UISwipeGestureRecognizer *)sender{
   
    //[self.navigationController popViewControllerAnimated:YES];
}

No comments:

Post a Comment