Saturday, 29 June 2013

How to use Swipe Gesture Recognizer iPhone ?

ViewController.h

@interface CoRoViewController : UIViewController<UIGestureRecognizerDelegate>

{
    UISwipeGestureRecognizer *gesture;


}

ViewController.m

-(void)viewDidLoad
{

 /* SWIPE GESTURE CODE */
    
    gesture = [[UISwipeGestureRecognizer alloc]init];
    [gesture setDirection:UISwipeGestureRecognizerDirectionLeft]; // you can use right or left ;)
    [gesture addTarget:self action:@selector(methodcalled)];
    
    gesture.delegate  = self;
    [self.view addGestureRecognizer:gesture];
}

-(void)methodcalled
{
      // Code you want to perform
}

Have fun :)

No comments:

Post a Comment