Mindmajix

How to use Gestures on the iPhone

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

The concrete sub classes are of the following:

A:   UITapGestureRecognizer

B:   UIRotationGestureRecognizer

C:   UISwpieGestureRecognizer

D:   UIPanGestureRecognizer

E:   UILongpressGestureRecognizer.

-(void) viewDidload
{

Capture 15// for tapping

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

Capture 15// for longPress:

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

Capture 15// 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];

Capture 15// for SwipeRight:

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

Capture 15// 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];

Capture 15// 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”);
}



0 Responses on How to use Gestures on the iPhone"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.