gesture-recognition

Implementing pinch zoom and drag using Android's build in gesture listener and scale listener

强颜欢笑 提交于 2019-11-26 19:06:53
问题 I am trying to implement pinch zoom and drag using Android's gesture listener and scale listener. The problem is that when I perform pinch zoom, the image (which I am trying to zoom) bounces to a particular location. Also the zoom position is not centered. The following code demonstrates what I am trying to achieve. Any idea why the image is jumping (and how to correct it) ? public class CustomView extends View { Bitmap image; int screenHeight; int screenWidth; Paint paint; GestureDetector

Store orientation to an array - and compare

落花浮王杯 提交于 2019-11-26 17:32:19
I want to achieve the following: I want the user to be able to "record" the movement of the iPhone using the gyroscope. And after that, the user should be able to replicate the same movement. I extract the pitch, roll and yaw using: [self.motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] withHandler: ^(CMDeviceMotion *motion, NSError *error) { CMAttitude *attitude = motion.attitude; NSLog(@"pitch: %f, roll: %f, yaw: %f]", attitude.pitch, attitude.roll, attitude.yaw); }]; I'm thinking that I could store these values into an array, if the user is in record mode. And

how detect swipe gesture direction?

家住魔仙堡 提交于 2019-11-26 15:59:52
问题 i need to detect direction of my swipe gesture and i've got problem with it. gesture is working, but i don't know how to detect direction. ... swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(detectSwipe:)]; [swipeGesture setNumberOfTouchesRequired:1]; [swipeGesture setDirection:UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionUp]; [appView addGestureRecognizer:swipeGesture]; -(void)detectSwipe:(UISwipeGestureRecognizer *)recognizer

Gesture problem: UISwipeGestureRecognizer + UISlider

坚强是说给别人听的谎言 提交于 2019-11-26 15:47:06
问题 Got a gesture related problem. I implemented UISwipeGestureRecognizer to get swipe left and right events and that is working fine. However the problem I'm facing is that the UISlider's I have in the same view are not playing nice. The sliding motion of the sliders is being mistaken as a swipe left/right. Any one experienced this problem before, got any ideas how to correct it? Many thanks. Here is the code contained within the view controller: - (void)viewDidLoad { [super viewDidLoad]; /

Long press on UITableView

吃可爱长大的小学妹 提交于 2019-11-26 15:36:46
I would like to handle a long press on a UITableViewCell to print a "quick access menu". Did someone already do this? Particularly the gesture recognize on UITableView ? First add the long press gesture recognizer to the table view: UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; lpgr.minimumPressDuration = 2.0; //seconds lpgr.delegate = self; [self.myTableView addGestureRecognizer:lpgr]; [lpgr release]; Then in the gesture handler: -(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer {

How to programmatically trigger the touch event in android?

这一生的挚爱 提交于 2019-11-26 09:34:40
问题 I would like to trigger a touch event like this: First the finger is touch down at the (0,50%) of the screen and slide to the (50%,50%) of the screen, and exit (move the finger off the screen) I have found some thing like this: MotionEvent event = MotionEvent.obtain(downTime, eventTime, action, x, y, pressure, size, metaState, xPrecision, yPrecision, deviceId, edgeFlags); onTouchEvent(event); However, how to emulate the above case? Do I need to create 2 event ? onTouchDown , onMove etc.... ?

Android Two finger rotation

半世苍凉 提交于 2019-11-26 09:16:19
问题 I am trying to implement two finger rotation in android however, it is not quite working as expected. The goal is to implement rotation like Google Earth does (two-finger rotating the image around the focal point). Currently my rotation listener looks like this: private class RotationGestureListener { private static final int INVALID_POINTER_ID = -1; private float fX, fY, sX, sY, focalX, focalY; private int ptrID1, ptrID2; public RotationGestureListener(){ ptrID1 = INVALID_POINTER_ID; ptrID2

What is the difference between Pan and Swipe in iOS?

烈酒焚心 提交于 2019-11-26 07:58:24
问题 Sounds simple .. Hold the Trackpad, move the finger, release .. But somehow swipe is not being triggered (pan is triggered instead) UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:v action:@selector(handleSwipe:)]; swipeGesture.direction= UISwipeGestureRecognizerDirectionUp; [v addGestureRecognizer:swipeGesture]; Pan is recognized by the above sequence instead. UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:v

Store orientation to an array - and compare

让人想犯罪 __ 提交于 2019-11-26 05:28:13
问题 I want to achieve the following: I want the user to be able to \"record\" the movement of the iPhone using the gyroscope. And after that, the user should be able to replicate the same movement. I extract the pitch, roll and yaw using: [self.motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] withHandler: ^(CMDeviceMotion *motion, NSError *error) { CMAttitude *attitude = motion.attitude; NSLog(@\"pitch: %f, roll: %f, yaw: %f]\", attitude.pitch, attitude.roll, attitude

Long press on UITableView

拥有回忆 提交于 2019-11-26 04:29:43
问题 I would like to handle a long press on a UITableViewCell to print a \"quick access menu\". Did someone already do this? Particularly the gesture recognize on UITableView ? 回答1: First add the long press gesture recognizer to the table view: UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; lpgr.minimumPressDuration = 2.0; //seconds lpgr.delegate = self; [self.myTableView addGestureRecognizer:lpgr]; [lpgr release]