MGBoxKit icon indicating copy to clipboard operation
MGBoxKit copied to clipboard

how handle left/right swipes?

Open icanzilb opened this issue 13 years ago • 4 comments

If there's only one swiper attached to a box, how to handle left AND right swipes?

icanzilb avatar Oct 06 '12 18:10 icanzilb

I meant - is it a more common case that a box can be swiped in only 1 direction? Does it not make more sense to have 4 recongizers attached to the box, and onSwipe to receive as a param the current direction for example?

icanzilb avatar Oct 06 '12 18:10 icanzilb

MGBox is providing a standard unmodified UISwipeGestureRecognizer. You'll want to configure the direction property:

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UISwipeGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/instp/UISwipeGestureRecognizer/direction

My preference would be for swipe gesture recognisers to optionally allow multiple swipe directions. I think the way Apple have done it is unnecessarily limiting. But certainly you could get around it by attaching additional recognisers and setting their action to the swiped method.

Alternatively MGBox could be modified to have onSwipedRight, onSwipedLeft, etc. That might be the better path, because it would make it explicit which direction the swipe was in.

sobri909 avatar Oct 06 '12 21:10 sobri909

Yeah, same direction of thought that I have ... like for my current project I just attached another gesture recogniser to the same box, but I realized I can't use the same onSwipe block to handle both, because then I don't know which direction the swipe was ...

I think onSwipedRight, onSwipedLeft, etc. is the right way

icanzilb avatar Oct 07 '12 12:10 icanzilb

An idea that just occurred to me, and that hasn't been thought out at all, so might be really stupid, is that all the gesture and tap handlers could be moved to a UIView category, thus decoupling them from MGBox and making them much more broadly usable.

Something to think about.

Anyway, the next time the onSwipe left/right limitation hits me I'll get that one fixed. It's silly.

sobri909 avatar Mar 27 '14 09:03 sobri909