简体   繁体   中英

Iphone : detecting drag / swipe direction starting from a button

I trying to make a swipe mechanism for a view that might have buttons on it. Without a button its a piece of cake.

However if your finger starts on the button, you can trigger an event (drag outside) but that does not tell me the direction.

So how can I detect the direction of a swipe / drag where your fingers starts on a button?

Any ideas?

Thanks Simon

It's still easy you just don't use the drag outside event. Look at the hitTest:withEvent in UIView to determine if it starts in the button or not. Along with UISwipeGestureRecognizer (or the touch event stuff) you should be fine.

Check out UISwipeGestureRecognizer . You ought to be able to just add it to your main view and have it recognize the gesture whether or not it originates on a button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM