Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect swiping left / right on the iPhone?

Is there any easy way to detect these kinds of gestures for iPhone? I can use touchesBegan, touchesMoved, touchesEnded. But how can I implement the gestures? thz u.

like image 995
Tattat Avatar asked May 03 '10 11:05

Tattat


People also ask

How do you swipe left and right on iPhone?

To browse the open apps, swipe right, then tap the app you want to use. See Switch between open apps on iPhone. Switch between open apps. Swipe right or left along the bottom edge of the screen to quickly switch between open apps.

How do you detect swipe?

Swiping in touch is the act of quickly moving your finger across the touch surface in a certain direction.

Why is my iPhone not swiping left or right?

Try and Force Restart your iPhone EXACTLY as shown below and see whether that resolves the issue: Press and quickly release Volume UP button. Press and quickly release Volume DOWN button. Press and Hold the SIDE button until an Apple logo appears and then release the Side button (Can take up to 20 seconds.

How do I turn on swipe gestures on iPhone?

To add or remove controls, go to Settings > Control Center. See Use and customize Control Center on iPhone. Open the App Switcher. Swipe up from the bottom edge, pause in the center of the screen, then lift your finger.


1 Answers

You will using UISwipeGestureRecognizer Object to detect the Touch and direction of Swipe In

UIView or anywhere in iphone sdk.

 UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
rightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[rightRecognizer setNumberOfTouchesRequired:1];

//add the your gestureRecognizer , where to detect the touch..
[view1 addGestureRecognizer:rightRecognizer];
[rightRecognizer release];

UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];
leftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[leftRecognizer setNumberOfTouchesRequired:1];

[view1 addGestureRecognizer:leftRecognizer];
[leftRecognizer release];

 - (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
 {
     NSLog(@"rightSwipeHandle");
 }

 - (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer 
 {
NSLog(@"leftSwipeHandle");
 }

I think this the Better solution for your problem

like image 190
Arunjack Avatar answered Sep 21 '22 14:09

Arunjack