How to use Gestures on the iPhone

  • (4.0)
  • | 1037 Ratings

UIgestures  recognizer is an abstract base class for concrete gesture – recognizer classes.

 A gestures- recognizer object (or, simply, a gesture recognizer) de couples the logic for recognizing a gesture and acting on that recognition.

When one of these objects recognizes a common gesture or in same classes, a change in the gesture, it sends an action message to each designated target object.

Inclined to build a profession as IOS Developer? Then here is the blog post on iPhone Development Certification Training.

The concrete sub classes are of the following:

A:   UITapGestureRecognizer
B:   UIRotationGestureRecognizer
C:   UISwpieGestureRecognizer
D:   UIPanGestureRecognizer
E:   UILongpressGestureRecognizer.

-(void) viewDidload

-->//for tapping

UITapGestureRecognizer     *recognizer  =
[[ UITapGestureRecognizer alloc] initWithTarget: self
Action:@ selector (gesture action)];
[ self view addGestureRecognizer: recognizer];
[ recognizer release];

-->//for longPress:

UIlongPressGestureRecognizer    * LongPress  =
[[ UILongPressGestureRecognizer alloc] initWithTarget: self
Action : @ Selector  ( gestureAction)];
[ self view addGestureRecognize  :   long press];
[ long press release];

- ->//for swipe left:

UISwipeGestureRecognizer       * swipe1=
[[UISwipeGestureRecognizer  alloc] initWithTarget : self
Action  : @ Selector   ( gesture Action left];
[Swipe1 setDirection : UISwipeGestureRecognizer. Direction left]
[ img view addGestureRecognizer   :  Swipe1];
[  Swipe1 release];

-->// for SwipeRight:

UISwipeGestureRecognizer          *Swipe r  =
[   UISwipe GestureRecognizer alloc]  initWith target  : self action:@  selector  (gestureActionRight)];
[ Swipe setDirection : UISwipeGesturRecognizerDirectionRight];
[  img view  addGestureRecognizer: swipe];
[  swipe r  release];

-->//for swipe up:

UISwipeGestureRecognizer          *swipe u  =
[[ UI SwipeGestureRecognizer alloc] init withTarget : self
action : @ Selector (gesture Action up)];
[SwipeU setDirection: UISwipeGestureRecognizerDirectionup];
[  imgview  addGestureRecognizer : SwipeU];
[ swipe u release];

-->/ for swipe down:

UISwipeGestureRecognizer         *swipe D=
[[ UISwipeGestureRecognizer alloc]  initWith target:  self
action  :@ Selector   (gesture  ActionDown)];
[ SwipeD   setDirection : UISwipeGestureRecognizerDirectionDown];
[  img view addGestureRecognizer:  swipe];
[   swipeD release];
-(void) gestureAction Left
NSLog (  @   “  view Swiped to Left”);
-( void) gestureActionRight
NSLog  (  @   “  view Swiped to Right”);
-(void) gestureActionup
NSLog (@ “view Swiped to up”);
-(void) gestureActionDowns
NSLog (@ “view Swiped to Down”);

Frequently Asked iPhone Interview Questions & Answers

Subscribe For Free Demo

Free Demo for Corporate & Online Trainings.

Ravindra Savaram
About The Author

Ravindra Savaram is a Content Lead at His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter. Protection Status