How to detect Swipe Gesture in iOS?

If You know how it works, but still need a quick example, here it is! (it will become handy at least for me, when I will need copy-paste example, without trying remembering it) UISwipeGestureRecognizer *mSwipeUpRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(doSomething)]; [mSwipeUpRecognizer setDirection:(UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight)]; [[self view] addGestureRecognizer:mSwipeUpRecognizer]; and in .h file … Read more

How to detect swipe in flutter

Use GestureDetector.onPanUpdate: GestureDetector( onPanUpdate: (details) { // Swiping in right direction. if (details.delta.dx > 0) {} // Swiping in left direction. if (details.delta.dx < 0) {} }, child: YourWidget(), ) To cover all the area (passing the parent constraints to the widget), you can include SizedBox.expand. SizedBox.expand( child: GestureDetector( onPanUpdate: (details) { // Swiping in … Read more

catch on swipe to dismiss event

DeleteIntent: DeleteIntent is a PendingIntent object that can be associated with a notification and gets fired when the notification gets deleted, ether by : User specific action User Delete all the notifications. You can set the Pending Intent to a broadcast Receiver and then perform any action you want. Intent intent = new Intent(this, MyBroadcastReceiver.class); … Read more

Custom edit view in UITableViewCell while swipe left. Objective-C or Swift

Just copy paste the code below! -(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@”Clona” handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ //insert your editAction here }]; editAction.backgroundColor = [UIColor blueColor]; UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@”Delete” handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ //insert your deleteAction here }]; deleteAction.backgroundColor = [UIColor redColor]; return @[deleteAction,editAction]; }

How to recognize swipe in all 4 directions

You need to have one UISwipeGestureRecognizer for each direction. It’s a little weird because the UISwipeGestureRecognizer.direction property is an options-style bit mask, but each recognizer can only handle one direction. You can send them all to the same handler if you want, and sort it out there, or send them to different handlers. Here’s one … Read more

Android Swipe on List

I had the same problem and I didn’t find my answer here. I wanted to detect a swipe action in ListView item and mark it as swiped, while continue to support OnItemClick and OnItemLongClick. Here is me solution: 1st The SwipeDetector class: import android.util.Log; import android.view.MotionEvent; import android.view.View; public class SwipeDetector implements View.OnTouchListener { public … Read more

Detect a finger swipe through JavaScript on the iPhone and Android

Simple vanilla JS code sample: document.addEventListener(‘touchstart’, handleTouchStart, false); document.addEventListener(‘touchmove’, handleTouchMove, false); var xDown = null; var yDown = null; function getTouches(evt) { return evt.touches || // browser API evt.originalEvent.touches; // jQuery } function handleTouchStart(evt) { const firstTouch = getTouches(evt)[0]; xDown = firstTouch.clientX; yDown = firstTouch.clientY; }; function handleTouchMove(evt) { if ( ! xDown || ! … Read more

Android: How to handle right to left swipe gestures

OnSwipeTouchListener.java: import android.content.Context; import android.view.GestureDetector; import android.view.GestureDetector.SimpleOnGestureListener; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; public class OnSwipeTouchListener implements OnTouchListener { private final GestureDetector gestureDetector; public OnSwipeTouchListener (Context ctx){ gestureDetector = new GestureDetector(ctx, new GestureListener()); } @Override public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } private final class GestureListener extends SimpleOnGestureListener { private static final … Read more