How to set more directions for UISwipeGestureRecognizer? - iphone

UISwipeGestureRecognizer has four directions that I can set: up, down, right, left.
but as I tried to set, the direction of a swipe seems need to be quite precise. I mean, for example, if I set a UISwipeGestureRecognizer with toUp direction, and if I swipe my finger not that precise toUp, say 45 degree in the middle of up and right, the UISwipeGestureRecognizer can't get it.
But I noticed that for UIScrollView, it is not the case.
So How can I give more directions for UISwipeGestureRecognizer or how can I make the direction check more relax?
Thanks

It's probably best to use Apple's swipe gesture to be consistent with their Apps. You could try defining your own by subclassing the UISwipeGestureRecognizer, or creating your own class using the older UITouchesBegan, UITouchesEnded, etc methods.

Related

How can I Know the force of a swipe Gesture Recognizers?

I want to move a image to the right or to the left with the swipe gesture recognizer, i´m already moving the image using the CCMoveTo function, but I don´t know how move the image faster or slower depends of the force of the swipe.
If the user make a strong swipe the image should move faster than if the user make a soft swipe.
Anyone have any advice?
A UISwipeGestureRecognizer is a one shot thing. It fires when the device detects the gesture and is done after that.
If you want more information about the movement of the finger you should check UIPanGestureRecognizer.
That's what the property velocity in the UIPanGestureRecognizer is for. You can see an example of how to use it in class 08 (I think) of cs193p by Paul Hegarty. Here's the link to download it from iTunes U

UIPanGestureRecognizer distance

Is it possible to change the distance of the UIPanGestureRecognizer before it will trigger?, the current implementation seems to have a distance margin of 5-10pixels before it is triggered, I would like to lower it if possible.
The reason is I use the UIPanGestureRecognizer in combination with the UIRotationGestureRecognizer to change the rotation of a object, with UIPanGestureRecognizer because of the distance margin it will not rotate right away and therefore the first rotation update will not be smooth (because it will go from 0 to something like 5degrees)
Nope. UIPanGestureRecognizer does not have any extra settings available on it. You could, however, write a custom gesture recognizer to do this.

How to drag view with two finger

Hi all:
I want to write a gesture recognizer on the iphone, that I cold use two finger to drag the view. Just like we use two finger on the MacBook Pro's touch pad.
If the view's size is larger than the window's size of the device, I could use two finger to drag the view. is there any good way to solve it ?
(Thanks enamrik and Naveen Thunga. I achieved my goal just now, but there is a new question that how could I know the UILongPressGestureRecognizer is over. I want call a method and set some value when my finger leaves the screen of my iphone.)
The UILongPressGestureRecognizer class has a numberOfTouchesRequired property you might find useful
Use uigesturerecognizer's properties and enable View's multitouch property. See some sample on UIGestureRecognizer that may help you.

Looking for direction for a Custom Gesture like swipe to scroll

I'm trying to have a sort of gesture that will seamlessly switch between a group of images this part I have sorted. The part that is catching me up is the gesture to do so and how I might introduce acceleration.
Basically the user would swipe as normal and after the swipe is registered it would change the image displayed and the faster once swiped the faster the image would change ideally it would then keep that speed until the users finger was lifted leaving the possibility to just scroll repeatedly through the images.
Any direction someone could give me would be great.
Thanks.
Assuming you would be using a UIScrollView for this, setting the scrollView.decelerationRate property would allow you to manipulate the deceleration rate/scroll speed. To calculate the "swipe speed", take a look here: Detecting Special touch on the iphone for some pointers.

Rotate a UIImageView with a touch gesture - iphone dev

Been having real trouble with this one and wondered if someone may have found a solution to this issue.
I would like to be able to rotate a UIImageView using a touch gesture
-> So when the user places two fingers on the touch area and rotates their fingers the UIImageView will rotate with them (Rotating in whatever direction the user moves their fingers)
I can do this but with one issue.... as the UIImageView rotates it does not keep its shape. It seems to skew?? It is really strange and i can not understand why it is happening.
So if i start with an equal sided square... as i rotate it does not remain as an equal sided square the sides seem to skew and not remain equal.
SOOOO i was wondering if anyone has come across this issue, or if anyone has successfully rotated a UIImageView with a touch gesture without it skewing.
Any help regarding this issue is highly appreciated.
Cheers
Tom
Can you give us some more information, like the rotation code?
Hopefully you're doing something like the following:
[imageView setTransform: CGAffineTransformMakeRotation(M_PI/2)];